* @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL * @license https://opensource.org/licenses/MIT The MIT License * * Don't forget to prefix your containers with your own identifier * to avoid any conflicts with others containers. */ require_once(dirname(__FILE__) . '/../RetailcrmPrestashopLoader.php'); class RetailcrmAbandonedCartsEvent extends RetailcrmAbstractEvent implements RetailcrmEventInterface { /** * @inheritDoc */ public function execute() { if ($this->isRunning()) { return false; } $this->setRunning(); $syncCartsActive = Configuration::get(RetailCRM::SYNC_CARTS_ACTIVE); if (empty($syncCartsActive)) { RetailcrmLogger::writeCaller(__METHOD__, 'Abandoned carts is disabled, skipping...'); return true; } $api = RetailcrmTools::getApiClient(); if (empty($api)) { RetailcrmLogger::writeCaller(__METHOD__, 'Set API key & URL first'); return true; } RetailcrmCartUploader::init(); RetailcrmCartUploader::$api = $api; RetailcrmCartUploader::$paymentTypes = array_keys(json_decode(Configuration::get(RetailCRM::PAYMENT), true)); RetailcrmCartUploader::$syncStatus = Configuration::get(RetailCRM::SYNC_CARTS_STATUS); RetailcrmCartUploader::setSyncDelay(Configuration::get(RetailCRM::SYNC_CARTS_DELAY)); RetailcrmCartUploader::run(); return true; } /** * @inheritDoc */ public function getName() { return 'RetailcrmAbandonedCartsEvent'; } }