コード例 #1
0
ファイル: cart.php プロジェクト: panickylemon/joomlastayn
 function add()
 {
     header("Cache-Control: no-cache, must-revalidate");
     if (!JshopHelpersCart::checkAdd()) {
         return 0;
     }
     $jshopConfig = JSFactory::getConfig();
     $ajax = JRequest::getInt('ajax');
     $product_id = JRequest::getInt('product_id');
     $category_id = JRequest::getInt('category_id');
     $quantity = JshopHelpersRequest::getQuantity();
     $attribut = JshopHelpersRequest::getAttribute();
     $to = JshopHelpersRequest::getCartTo();
     $freeattribut = JshopHelpersRequest::getFreeAttribute();
     $checkout = JSFactory::getModel('checkout', 'jshop');
     $checkout->setMaxStep(2);
     $cart = JSFactory::getModel('cart', 'jshop');
     $cart->load($to);
     if (!$cart->add($product_id, $quantity, $attribut, $freeattribut)) {
         if ($ajax) {
             print getMessageJson();
             die;
         }
         $modelproduct = JSFactory::getModel('productShop', 'jshop');
         $modelproduct->setBackValue(array('pid' => $product_id, 'attr' => $attribut, 'freeattr' => $freeattribut, 'qty' => $quantity));
         $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=product&task=view&category_id=' . $category_id . '&product_id=' . $product_id, 1, 1));
         return 0;
     }
     if ($ajax) {
         print getOkMessageJson($cart);
         die;
     }
     if ($jshopConfig->not_redirect_in_cart_after_buy) {
         $this->setRedirect($_SERVER['HTTP_REFERER'], $cart->getMessageAddToCart());
         return 1;
     }
     if ($to == "cart") {
         $defaultitemid = 0;
     } else {
         $defaultitemid = 1;
     }
     $this->setRedirect(SEFLink($cart->getUrlList(), $defaultitemid, 1));
 }
コード例 #2
0
ファイル: product.php プロジェクト: panickylemon/joomlastayn
 function ajax_attrib_select_and_price()
 {
     $request = JRequest::get('request');
     $product_id = JRequest::getInt('product_id');
     $change_attr = JRequest::getInt('change_attr');
     $qty = JshopHelpersRequest::getQuantity('qty', 1);
     $attribs = JshopHelpersRequest::getAttribute('attr');
     $freeattr = JshopHelpersRequest::getFreeAttribute('freeattr');
     $model = JSFactory::getModel('productAjaxRequest', 'jshop');
     $model->setData($product_id, $change_attr, $qty, $attribs, $freeattr, $request);
     print $model->getProductDataJson();
     die;
 }