public function actionUpdateAmount()
 {
     $cart = Shop::getCartContent();
     foreach ($_GET as $key => $value) {
         if (substr($key, 0, 7) == 'amount_') {
             if ($value == '') {
                 return true;
             }
             if (!is_numeric($value) || $value <= 0) {
                 throw new CException('Wrong amount');
             }
             $position = explode('_', $key);
             $position = $position[1];
             if (isset($cart[$position]['amount'])) {
                 $cart[$position]['amount'] = $value;
             }
             $product = Products::model()->findByPk($cart[$position]['product_id']);
             echo Shop::priceFormat(@$product->getPrice($cart[$position]['Variations'], $value));
             return Shop::setCartContent($cart);
         }
     }
 }
Example #2
0
 public static function flushCart($full = false)
 {
     if ($full) {
         Yii::app()->user->setState('cart', array());
         Yii::app()->user->setState('shipping_method', null);
         Yii::app()->user->setState('payment_method', null);
         Yii::app()->user->setState('order_comment', null);
     }
     return Shop::setCartContent(array());
 }