ajax) { http_response_code(400); exit; } $choice = Tools::getValue('gift_paper', ''); $saved = Configuration::get(Config::CONFIG_KEY); $options = $saved ? json_decode($saved, true) : Config::DEFAULT_OPTIONS; if (!in_array($choice, $options, true)) { $this->ajaxRender(json_encode(['success' => false, 'error' => 'Invalid option'])); exit; } $idCart = (int) $this->context->cart->id; if (!$idCart) { $this->ajaxRender(json_encode(['success' => false, 'error' => 'No cart'])); exit; } Db::getInstance()->execute( 'INSERT INTO `' . _DB_PREFIX_ . 'ws_gift_dropdown` (`id_cart`, `id_order`, `paper_choice`, `date_add`) VALUES (' . (int) $idCart . ', 0, \'' . pSQL($choice) . '\', NOW()) ON DUPLICATE KEY UPDATE `paper_choice` = \'' . pSQL($choice) . '\', `date_add` = NOW()' ); $this->ajaxRender(json_encode(['success' => true])); exit; } }