public function preProcess() { parent::preProcess(); //Add or remove product with Ajax if (Tools::getValue('ajax') and Tools::getValue('id_product') and Tools::getValue('action')) { if (Tools::getValue('action') == 'add') { if (isset(self::$cookie->id_customer)) { if (CompareProduct::getCustomerNumberProducts(self::$cookie->id_customer) < Configuration::get('PS_COMPARATOR_MAX_ITEM')) { CompareProduct::addCustomerCompareProduct((int) self::$cookie->id_customer, (int) Tools::getValue('id_product')); } else { die('0'); } } else { if (isset(self::$cookie->id_guest) and CompareProduct::getGuestNumberProducts(self::$cookie->id_guest) < Configuration::get('PS_COMPARATOR_MAX_ITEM')) { CompareProduct::addGuestCompareProduct((int) self::$cookie->id_guest, (int) Tools::getValue('id_product')); } else { die('0'); } } } elseif (Tools::getValue('action') == 'remove') { if (isset(self::$cookie->id_customer)) { CompareProduct::removeCustomerCompareProduct((int) self::$cookie->id_customer, (int) Tools::getValue('id_product')); } elseif (isset(self::$cookie->id_guest)) { CompareProduct::removeGuestCompareProduct((int) self::$cookie->id_guest, (int) Tools::getValue('id_product')); } else { die('0'); } } else { die('0'); } die('1'); } }