예제 #1
0
 function changeItem()
 {
     $itemId = JRequest::getVar('itemId');
     $value = JRequest::getVar('value', 1, 'method', 'int');
     if (empty($value)) {
         $value = 1;
     }
     $buy4friend = JRequest::getVar('buy4friend', 0, 'method', 'int');
     //-----------------------------
     // get max purchase per user allowed and check if the update qty is > or not
     $maxBuyQtyOfDeal = EnmasseHelper::getMaxBuyQtyOfDeal($itemId);
     if ($maxBuyQtyOfDeal >= 0 && $value > $maxBuyQtyOfDeal) {
         $msg = JText::_("ITEM_UPDATE_GREATER_THAN_MAX");
         JFactory::getApplication()->redirect("index.php?option=com_enmasse&controller=shopping&task=checkout", $msg);
     }
     $cart = unserialize(JFactory::getSession()->get('cart'));
     CartHelper::checkCart($cart);
     $cart->changeItem($itemId, $value);
     JFactory::getSession()->set('cart', serialize($cart));
     $msg = JText::_("ITEM_UPDATE_MSG");
     $link = JRoute::_("index.php?option=com_enmasse&controller=shopping&task=checkout&buy4friend={$buy4friend}", false);
     JFactory::getApplication()->redirect($link, $msg);
 }