Welcome, Guest
Username: Password: Remember me

TOPIC: Amount limit not correct

Amount limit not correct 7 years 6 months ago #1711

  • scottjoseph
  • scottjoseph's Avatar
  • Offline
  • Fresh Boarder
  • Posts: 13
  • Thank you received: 1
  • Karma: 0
In one of the deals I'm currently offering the "maximum bought" quantity is set to 4. Yet the drop-down in the front end displays 1-10. One of my buyers purchased 10 coupons and the link that was sent to her does not work. I have to manually produce and email the certificates to her. Is there a fix for this? Here is a link to the deal: www.scottjosephorlando.com/index.php/ext...ents/restaurant-deal
The administrator has disabled public write access.

Amount limit not correct 7 years 6 months ago #1713

  • hungtran
  • hungtran's Avatar
  • Offline
  • Moderator
  • Posts: 1636
  • Thank you received: 245
  • Karma: 27
Hi,

Guest is allowed to purchase on your site, so max bought for each user will not work. This function doesn't only check for current order's quantity but also checks for orders in the past, so user must be a registered user.

If you want to allow this function for guest, you can customize components/com_cmgroupbuying/helpers/cart.php,

replace
                            // Only check for registered users
                            $user = JFactory::getUser();

                            if(!$user->guest)
                            {
                                $pastCoupons    = CMGroupBuyingHelperDeal::getCouponsOfUserForDeal($user->get('id'), $deal['id']);
                                $coupons        = $pastCoupons + $quantity;

                                if($deal['max_bought'] < $coupons)
                                {
                                    $return['error']    = true;
                                    $return['message']  = JText::_('COM_CMGROUPBUYING_UPDATE_CART_LIMIT_BOUGHT_MESSAGE');
                                    $return['type']     = 'error';
                                    return $return;
                                }
                            }

with
                            $user = JFactory::getUser();

                            if($user->guest)
                            {                                
                                $coupons = $quantity;
                            }
                            else
                            {
                                $pastCoupons    = CMGroupBuyingHelperDeal::getCouponsOfUserForDeal($user->get('id'), $deal['id']);
                                $coupons        = $pastCoupons + $quantity;
                            }

                                if($deal['max_bought'] < $coupons)
                                {
                                    $return['error']    = true;
                                    $return['message']  = JText::_('COM_CMGROUPBUYING_UPDATE_CART_LIMIT_BOUGHT_MESSAGE');
                                    $return['type']     = 'error';
                                    return $return;
                                }

However, your guest still can make another purchase to get more than the limit you set, as a guest he doesn't have any record in database to check.

I hope this helps.

Regards,
Hung
The administrator has disabled public write access.