1 reply [Last post]
grobot's picture
Offline
Joined: 04/12/2008
Juice: 289
Was this information Helpful?

Our store sells download items, and I want to assign newly registered users some free downloads after registering.

I'd rather they didn't have to use a coupon - I want to "credit" their user a/c with n free downloads, and then start charging them after that.

Is there a module which does this already?

--

Full details:

We sell a print publication, and owners of the print edition can also log in to download additional articles.

They get quizzed on user rego to answer a question which proves they have access to a print copy. ("What's the first word on page xxx?")

If they answer that correctly, they get some free downloads.

In the old system, I would track this value against their user, and if the current user has free downloads available, replace the "Buy now" link with "Download for free", using a PHP script which would decrement their downloads value and return the PDF file.

Now that we are moving to UC, I'd like to track these downloads as "free" purchases, which means we can use the cart system and have more useful product reporting integrated. So ... the idea of having product credits which customers can use is appealing.

--

Suggestions and module pointers welcome!

Thanks in advance

Giant Robot - for campaign, charity, ngo & online store solutions - www.giantrobot.co.nz

grobot's picture
Offline
Joined: 04/12/2008
Juice: 289
simple solution - is this the best approach?

Concept one - based on recent work I did with the uc_supplier module:

Use hook_nodeapi() to alter the product price at load time. This should mean that when the user has n credits, and adds n+2 items to their cart, they only pay for the last two.

Untested code - based on code from uc_supplier (which adjusts prices based on imported supplier CSVs):

<?php
function mymodule_nodeapi( &$node, $op, $teaser = NULL, $page = NULL ) {
  switch(
$op ) {
    case
"load" :
     
// there's a better uc_ function i should use here to tell if an item
      // is a uc product or not, but i forget what it is :)
     
if ( isset($node->model) && isset($node->list_price) && isset($node->sell_price) ) {
        global
$user ;
        if ( isset(
$user->credits) && $user->credits > 0 ) {
         
$node->sell_price = 0 ;
         
$user->credits-- ;
        }
      }
      break ;
  }
}

?>

Giant Robot - for campaign, charity, ngo & online store solutions - www.giantrobot.co.nz