Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Class AjaxBasketAddAction
- * @property int $product_id
- */
- class AjaxBasketChangeCountAction extends \Majestic\App\AjaxAction {
- /**
- * @var OrderModel
- */
- private $order_model;
- /**
- * @var ProductModel
- */
- private $product_model;
- var $product_id;
- var $stock_id;
- public function __construct()
- {
- $this->order_model = new OrderModel();
- $this->product_model = new ProductModel();
- parent::__construct();
- }
- public function execute()
- {
- if ( !( $product = $this->product_model->get( $this->product_id ) ) ) {
- $message = 'Product not found. Id ' . $this->product_id;
- App::abort( 404, $message );
- }
- switch ( \Majestic\Env::getParam( 'method' ) ) {
- case 'increase':
- $this->order_model->increaseProductCount( $this->product_id, $this->stock_id );
- break;
- case 'decrease':
- $this->order_model->decreaseProductCount( $this->product_id, $this->stock_id );
- break;
- }
- if ( !\Majestic\Env::Post( 'is_ajax' ) ) {
- $this->redirect( '/order/basket' );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement