5 replies [Last post]
gtothab's picture
Offline
Joined: 03/26/2009
Juice: 58
Was this information Helpful?

Hey. Can I make users NOT be able to modify the QTY. of their prodcut in the cart? I'm selling registrations to events via the node_checkout mod. and I cant have people buying more than one event at a time. So i need them to not be able to add from within the cart.

Anyone got an idea?

thanks

netslave's picture
Offline
Joined: 05/22/2008
Juice: 187
Re: Can I make users NOT be able to modify the QTY. of their pro

You must implement a hook_uc_add_to_cart.

Could be so : ( NOT TESTED !!! )

<?php
function my_module_uc_add_to_cart($nid, $qty, $data)
{
    
$contents = uc_cart_get_contents();
     if (
$qty > 1 ) return array(array(
               
'success' => false,
               
'message' => t('You can book this event only once a time')
            ));
     foreach (
$content as $key => $product )
     {
         if (
$nid === $product->nid )
         {
             return array(array(
               
'success' => false,
               
'message' => t('You can book this event only once a time')
            ));
         }
     }
}
?>
gtothab's picture
Offline
Joined: 03/26/2009
Juice: 58
Close but. . .

Hey thx for replying. So, that made the cart not appear after hitting add to cart. So the user is unable to complete the checkout. . . . Any idea on why?

thx again.

leenwebb's picture
Offline
Joined: 06/01/2008
Juice: 248
Re: Close but. . .

Another way to go would be to use a little jQuery magic to disable the Qty field in the form. (Not that I have an example at hand, since js code takes me forever and day to write, but it shouldn't be too hard to figure out.)

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4110
Re: Re: Close but. . .

Have you already tried this? http://drupal.org/project/uc_restrict_qty

--
Help directly fund development: Donate via PayPal!

gtothab's picture
Offline
Joined: 03/26/2009
Juice: 58
yes!!

Yes man! that worked like a charm!! thanks so much. TICKED CLOSED Smiling