Ejemplo n.º 1
0
 public function init()
 {
     parent::init();
     if (Module::isEnabled('aimultidimensions')) {
         if (Tools::getIsset('add') && $this->context->cart->id) {
             require_once _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'aimultidimensions' . DIRECTORY_SEPARATOR . 'aimultidimensions.php';
             require_once _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'aimultidimensions' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'config.php';
             require_once _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'aimultidimensions' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'functions' . $GLOBALS['aimd_config_suffix'] . '.php';
             $add = 1;
             $idProduct = (int) Tools::getValue('id_product', NULL);
             if (checkLink($idProduct)) {
                 $idProductAttribute = (int) Tools::getValue('id_product_attribute', Tools::getValue('ipa'));
                 $customizationId = (int) Tools::getValue('id_customization', 0);
                 $qty = (int) abs(Tools::getValue('qty', 1));
                 if ($add && $qty >= 0 && getProducts($idProduct)) {
                     $quantity = (int) Db::getInstance()->getValue('SELECT quantity FROM ' . _DB_PREFIX_ . 'cart_product WHERE id_cart = ' . $this->context->cart->id . ' AND id_product = ' . $idProduct . ' AND ' . 'id_product_attribute = ' . $idProductAttribute);
                     if (Tools::getValue('op', 'up') == 'up') {
                         $quantity += (int) $qty;
                     } else {
                         $quantity -= (int) $qty;
                     }
                     $cookie = $this->context->cookie;
                     $cart = $this->context->cart;
                     include_once 'modules/aimultidimensions/includes/cart.php';
                     Product::flushPriceCache();
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 public function preProcess()
 {
     if (!sizeof($this->errors)) {
         $add = Tools::getIsset('add') ? 1 : 0;
         $idProduct = (int) Tools::getValue('id_product', NULL);
         $idProductAttribute = (int) Tools::getValue('id_product_attribute', Tools::getValue('ipa'));
         $customizationId = (int) Tools::getValue('id_customization', 0);
         $qty = (int) abs(Tools::getValue('qty', 1));
         if ($add and $qty >= 0) {
             $quantity = (int) Db::getInstance()->getValue('SELECT quantity FROM ' . _DB_PREFIX_ . 'cart_product WHERE id_cart = ' . self::$cart->id . ' AND id_product = ' . $idProduct . ' AND id_product_attribute = ' . $idProductAttribute);
             if (Tools::getValue('op', 'up') == 'up') {
                 $quantity += (int) $qty;
             } else {
                 $quantity -= (int) $qty;
             }
             // Update the product price and quantity for multidimensionnal
             require_once _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'aimultidimensions' . DIRECTORY_SEPARATOR . 'aimultidimensions.php';
             include_once 'modules/aimultidimensions/includes/cart.php';
         }
     }
     parent::preProcess();
 }