Skip to content

Commit

Permalink
Abandoned cart sends all fields available to api.
Browse files Browse the repository at this point in the history
Added upgrade file for altering database.
Changed wording in settings page.
  • Loading branch information
sinukaarel committed Jan 22, 2019
1 parent 7a677de commit 3a875bb
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 5 deletions.
22 changes: 19 additions & 3 deletions controllers/front/SmailyCron.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ private function abandonedCart()
$reminder_time = strtotime('+' . $delay . ' hours', $cart_updated_time);
$current_time = strtotime(date('Y-m-d H:i') . ':00');

// Continue with data gathering only if there is an email value to send data to.
if (empty($abandoned_cart['email'])) {
continue;
}
// Check if mail has allready been sent about this cart
$id_customer = (int) $abandoned_cart['id_customer'];
$id_cart = (int) $abandoned_cart['id_cart'];
Expand All @@ -151,10 +155,22 @@ private function abandonedCart()

$adresses = array(
'email' => $abandoned_cart['email'],
'firstname' => $abandoned_cart['firstname'],
'lastname' => $abandoned_cart['lastname'],
'firstname' => isset($abandoned_cart['firstname']) ? $abandoned_cart['firstname'] : '',
'lastname' => isset($abandoned_cart['lastname']) ? $abandoned_cart['lastname'] :'',
);

// Empty products array for legacy API. All fields are set to empty string.
$fields_available = array(
'product_name',
'product_description_short',
'product_price',
'product_category',
'procuct_quantity',
);
for ($i=1; $i < 11; $i++) {
foreach ($fields_available as $field) {
$adresses[ $field . '_' . $i ] = '';
}
}
// Collect products of abandoned cart.
if (!empty($products)) {
$i = 1;
Expand Down
2 changes: 1 addition & 1 deletion translations/et.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
$_MODULE['<{smailyforprestashop}prestashop>smailycron_ff0f6b0cf4d70ad36a09f7079be3f546'] = 'Unustatud ostukorvi meeldetuletus deaktiveeritud!';
$_MODULE['<{smailyforprestashop}prestashop>smailycron_b55a2b2d84680417f12898a11647a1cb'] = 'Vale kasutajatunnus või parool!';
$_MODULE['<{smailyforprestashop}prestashop>smaily_configure_05118375527d94e35408da46efdce0e5'] = 'Smaily Mooduli Sätted';
$_MODULE['<{smailyforprestashop}prestashop>smaily_configure_b689be7d5235c3ec45ec989d993c5355'] = 'Aktiveeri kasutajate sünkroniseerimine';
$_MODULE['<{smailyforprestashop}prestashop>smaily_configure_a69d72ba4abe9915e183bcd00d8fcc42'] = 'Käivita Kasutajate Sünkroniseerimine';
$_MODULE['<{smailyforprestashop}prestashop>smaily_configure_93cba07454f06a4a960172bbd6e2a435'] = 'Jah';
$_MODULE['<{smailyforprestashop}prestashop>smaily_configure_bafd7322c6e97d25b6299b5d6fe8920b'] = 'Ei';
$_MODULE['<{smailyforprestashop}prestashop>smaily_configure_beed05bccb8b6f21466910eb4a4f142b'] = 'Alamdomeen';
Expand Down
42 changes: 42 additions & 0 deletions upgrade/Upgrade-1.1.0.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
/**
* 2018 Smaily
*
* NOTICE OF LICENSE
*
* Smaily for PrestaShop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Smaily for PrestaShop is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Smaily for PrestaShop. If not, see <http://www.gnu.org/licenses/>.
*
* @author Smaily <[email protected]>
* @copyright 2018 Smaily
* @license GPL3
*/

if (!defined('_PS_VERSION_')) {
exit;
}

/**
* Upgrades database with smaily abandoned cart table.
*
*/
function upgrade_module_1_1_0()
{
return Db::getInstance()->execute(
'CREATE TABLE IF NOT EXISTS '._DB_PREFIX_.'smaily_cart (
`id_smaily_cart` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`id_customer` INT UNSIGNED NULL ,
`id_cart` INT UNSIGNED NULL ,
`date_sent` DATETIME NOT NULL) ENGINE='._MYSQL_ENGINE_
);
}
31 changes: 31 additions & 0 deletions upgrade/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* 2018 Smaily
*
* NOTICE OF LICENSE
*
* Smaily for PrestaShop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Smaily for PrestaShop is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Smaily for PrestaShop. If not, see <http://www.gnu.org/licenses/>.
*
* @author Smaily <[email protected]>
* @copyright 2018 Smaily
* @license GPL3
*/

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;
2 changes: 1 addition & 1 deletion views/templates/admin/smaily_configure.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<div class="form-wrapper">
<div class="form-group">
<label class="control-label col-lg-3">
{l s="Enable Cron" mod='smailyforprestashop'}
{l s="Enable Customer Synchronization" mod='smailyforprestashop'}
</label>
<div class="col-lg-9">
<span class="switch prestashop-switch fixed-width-lg">
Expand Down

0 comments on commit 3a875bb

Please sign in to comment.