Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function actionIncart(){
- $product = Catalog::model()->findByPk($_POST['id']);
- $sizes = explode(',', $product->size);
- $count = explode(',', $product->count);
- $size_count = 0;
- if(isset($_POST['size'])){
- foreach($sizes as $key=>$size){
- if($_POST['size'] == $size){
- $size_count = $count[$key];
- }
- }
- $product->chosenSize = $_POST['size'];
- $position = Yii::app()->shoppingCart->itemAt($_POST['id'].'_'.$_POST['size']);
- if($position){
- $count_cart = $position->getQuantity()+1;
- if($count_cart <= $size_count){
- Yii::app()->shoppingCart->put($product);
- echo Yii::app()->shoppingCart->getItemsCount();
- } else {
- echo false;
- }
- } else {
- Yii::app()->shoppingCart->put($product);
- echo Yii::app()->shoppingCart->getItemsCount();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement