process(); class ApAjax{ public function __construct(){ } public function process(){ $lifetime = (int)Tools::getValue('lifetime'); $update = (int)Tools::getValue('update'); switch (Tools::getValue('ap_event')) { case 'cart': case 'customer': case 'product': case 'concours': case 'promo': die(Tools::JsonEncode($response = $this->processYield(Tools::getValue('ap_event'), $update, $lifetime))); break; default: die(0); break; } } private function processYield($event, $update = false, $lifetime = 3600){ $cookie = $this->getCookie('ps_ant_popover_cart' . $event . Context::getContext()->shop->id); if ($update){ $cookie->event_date = time(); return false; } if (!isset($cookie->event_date) || time() > $cookie->event_date + $lifetime){ return true; } return false; } private function getCookie($cookie_name){ $cookie = new Cookie($cookie_name); if (!$cookie->exists()) $cookie = $this->createCookie($cookie_name); return $cookie; } private function createCookie($cookie_name){ return new Cookie($cookie_name); } }