cartsguru - Version 1.2.16

Version Notes

- Added language, isNewCustomer and customer group into custom variables

Download this release

Release Info

Developer Maxime Pruvost
Extension cartsguru
Version 1.2.16
Comparing to
See all releases


Code changes from version 1.2.15 to 1.2.16

app/code/local/Cartsguru/Helper/Data.php CHANGED
@@ -4,7 +4,46 @@
4
  * Class of Magento core helper abstraction
5
  * Class Cartsguru_Helper_Data
6
  */
7
- class Cartsguru_Helper_Data extends Mage_Core_Helper_Abstract
8
- {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  * Class of Magento core helper abstraction
5
  * Class Cartsguru_Helper_Data
6
  */
7
+ class Cartsguru_Helper_Data extends Mage_Core_Helper_Abstract
8
+ {
9
+ // Get customer language from browser
10
+ public function getBrowserLanguage()
11
+ {
12
+ if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
13
+ foreach (explode(",", strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE'])) as $accept) {
14
+ if (preg_match("!([a-z-]+)(;q=([0-9\\.]+))?!", trim($accept), $found)) {
15
+ $langs[] = $found[1];
16
+ $quality[] = (isset($found[3]) ? (float) $found[3] : 1.0);
17
+ }
18
+ }
19
+ // Order the codes by quality
20
+ array_multisort($quality, SORT_NUMERIC, SORT_DESC, $langs);
21
+ // get list of stores and use the store code for the key
22
+ $stores = Mage::app()->getStores(false, true);
23
+ // iterate through languages found in the accept-language header
24
+ foreach ($langs as $lang) {
25
+ $lang = substr($lang, 0, 2);
26
+ return $lang;
27
+ }
28
+ }
29
+ return null;
30
+ }
31
 
32
+ // Get customer group name
33
+ public function getCustomerGroupName()
34
+ {
35
+ $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
36
+ $groupName = Mage::getSingleton('customer/group')->load($groupId)->getData('customer_group_code');
37
+ return strtolower($groupName);
38
+ }
39
+
40
+ // Check if customer has orders
41
+ public function isNewCustomer($email)
42
+ {
43
+ if ($email && $email !== '') {
44
+ $orders = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('customer_email', $email);
45
+ return $orders->count() === 0;
46
+ }
47
+ return false;
48
+ }
49
+ }
app/code/local/Cartsguru/Model/Webservice.php CHANGED
@@ -17,7 +17,7 @@ class Cartsguru_Model_Webservice
17
  const QUOTES_CACHE_TAG = 'cartsguru_carts';
18
  const QUOTES_CACHE_TTL = 1800; // 30min in seconds
19
 
20
- const _CARTSGURU_VERSION_ = '1.2.14';
21
 
22
  protected function getStoreFromAdmin(){
23
  $store_id = null;
@@ -219,6 +219,7 @@ class Cartsguru_Model_Webservice
219
  */
220
  public function getOrderData($order, $store = null)
221
  {
 
222
  //Order must have a status
223
  if (!$order->getStatus()){
224
  return null;
@@ -234,6 +235,13 @@ class Cartsguru_Model_Webservice
234
  //Items details
235
  $items = $this->getItemsData($order);
236
 
 
 
 
 
 
 
 
237
  return array(
238
  'siteId' => $this->getStoreConfig('siteid', $store), // SiteId is part of plugin configuration
239
  'id' => $order->getIncrementId(), // Order reference, the same display to the buyer
@@ -252,7 +260,8 @@ class Cartsguru_Model_Webservice
252
  'email' => $this->notEmpty($email), // Email of the buye
253
  'phoneNumber' => $this->notEmpty($address->getTelephone()), // Landline phone number of buyer (internationnal format)
254
  'countryCode' => $this->notEmpty($address->getCountryId()), // Country code of buyer
255
- 'items' => $items // Details
 
256
  );
257
  }
258
 
@@ -270,7 +279,7 @@ class Cartsguru_Model_Webservice
270
  }
271
 
272
  //Get data, stop if none
273
- $orderData = $this->getOrderData($order,$store);
274
  if (empty($orderData)) {
275
  return;
276
  }
@@ -302,6 +311,7 @@ class Cartsguru_Model_Webservice
302
  */
303
  public function getAbadonnedCartData($quote, $store = null)
304
  {
 
305
  //Customer data
306
  $gender = $this->genderMapping($quote->getCustomerGender());
307
 
@@ -326,7 +336,7 @@ class Cartsguru_Model_Webservice
326
  }
327
  }
328
 
329
- if ($address){
330
  if (!$phone){
331
  $phone = $address->getTelephone();
332
  }
@@ -335,7 +345,7 @@ class Cartsguru_Model_Webservice
335
  }
336
  }
337
 
338
- if ($customer){
339
  $customerAddress = $customer->getDefaultBillingAddress();
340
 
341
  if ($customerAddress && !$phone){
@@ -346,6 +356,13 @@ class Cartsguru_Model_Webservice
346
  }
347
  }
348
 
 
 
 
 
 
 
 
349
  //Recover link
350
  $recoverUrl = ($quote->getData('cartsguru_token')) ?
351
  Mage::getBaseUrl() . 'cartsguru/recovercart?cart_id=' . $quote->getId() . '&cart_token=' . $quote->getData('cartsguru_token') :
@@ -375,7 +392,8 @@ class Cartsguru_Model_Webservice
375
  'phoneNumber' => $this->notEmpty($phone), // Landline phone number of buyer (internationnal format)
376
  'countryCode' => $this->notEmpty($country), // Country code of the buyer
377
  'recoverUrl' => $recoverUrl, // Direct link to recover the cart
378
- 'items' => $items // Details
 
379
  );
380
  }
381
 
@@ -466,7 +484,7 @@ class Cartsguru_Model_Webservice
466
 
467
  return array(
468
  'siteId' => $this->getStoreConfig('siteid', $store), // SiteId is part of plugin configuration
469
- 'accountId' => $customer->getId(), // Account id of the customer
470
  'civility' => $gender, // Use string in this list : 'mister','madam','miss'
471
  'lastname' => $this->notEmpty($lastname), // Lastname of the buyer
472
  'firstname' => $this->notEmpty($firstname), // Firstname of the buyer
17
  const QUOTES_CACHE_TAG = 'cartsguru_carts';
18
  const QUOTES_CACHE_TTL = 1800; // 30min in seconds
19
 
20
+ const _CARTSGURU_VERSION_ = '1.2.16';
21
 
22
  protected function getStoreFromAdmin(){
23
  $store_id = null;
219
  */
220
  public function getOrderData($order, $store = null)
221
  {
222
+ $helper = Mage::helper('cartsguru');
223
  //Order must have a status
224
  if (!$order->getStatus()){
225
  return null;
235
  //Items details
236
  $items = $this->getItemsData($order);
237
 
238
+ // Custom fields
239
+ $custom = array(
240
+ 'language' => $helper->getBrowserLanguage(),
241
+ 'customerGroup' => $helper->getCustomerGroupName(),
242
+ 'isNewCustomer' => $helper->isNewCustomer($email)
243
+ );
244
+
245
  return array(
246
  'siteId' => $this->getStoreConfig('siteid', $store), // SiteId is part of plugin configuration
247
  'id' => $order->getIncrementId(), // Order reference, the same display to the buyer
260
  'email' => $this->notEmpty($email), // Email of the buye
261
  'phoneNumber' => $this->notEmpty($address->getTelephone()), // Landline phone number of buyer (internationnal format)
262
  'countryCode' => $this->notEmpty($address->getCountryId()), // Country code of buyer
263
+ 'items' => $items, // Details
264
+ 'custom' => $custom // Custom fields array
265
  );
266
  }
267
 
279
  }
280
 
281
  //Get data, stop if none
282
+ $orderData = $this->getOrderData($order, $store);
283
  if (empty($orderData)) {
284
  return;
285
  }
311
  */
312
  public function getAbadonnedCartData($quote, $store = null)
313
  {
314
+ $helper = Mage::helper('cartsguru');
315
  //Customer data
316
  $gender = $this->genderMapping($quote->getCustomerGender());
317
 
336
  }
337
  }
338
 
339
+ if ($address) {
340
  if (!$phone){
341
  $phone = $address->getTelephone();
342
  }
345
  }
346
  }
347
 
348
+ if ($customer) {
349
  $customerAddress = $customer->getDefaultBillingAddress();
350
 
351
  if ($customerAddress && !$phone){
356
  }
357
  }
358
 
359
+ // Custom fields
360
+ $custom = array(
361
+ 'language' => $helper->getBrowserLanguage(),
362
+ 'customerGroup' => $helper->getCustomerGroupName(),
363
+ 'isNewCustomer' => $helper->isNewCustomer($email)
364
+ );
365
+
366
  //Recover link
367
  $recoverUrl = ($quote->getData('cartsguru_token')) ?
368
  Mage::getBaseUrl() . 'cartsguru/recovercart?cart_id=' . $quote->getId() . '&cart_token=' . $quote->getData('cartsguru_token') :
392
  'phoneNumber' => $this->notEmpty($phone), // Landline phone number of buyer (internationnal format)
393
  'countryCode' => $this->notEmpty($country), // Country code of the buyer
394
  'recoverUrl' => $recoverUrl, // Direct link to recover the cart
395
+ 'items' => $items, // Details
396
+ 'custom' => $custom // Custom fields array
397
  );
398
  }
399
 
484
 
485
  return array(
486
  'siteId' => $this->getStoreConfig('siteid', $store), // SiteId is part of plugin configuration
487
+ 'accountId' => $customer->getEmail(), // Account id of the customer
488
  'civility' => $gender, // Use string in this list : 'mister','madam','miss'
489
  'lastname' => $this->notEmpty($lastname), // Lastname of the buyer
490
  'firstname' => $this->notEmpty($firstname), // Firstname of the buyer
app/code/local/Cartsguru/etc/config.xml CHANGED
@@ -3,7 +3,7 @@
3
  <!-- plugin name -->
4
  <modules>
5
  <Cartsguru>
6
- <version>1.2.14</version>
7
  </Cartsguru>
8
  </modules>
9
  <global>
3
  <!-- plugin name -->
4
  <modules>
5
  <Cartsguru>
6
+ <version>1.2.16</version>
7
  </Cartsguru>
8
  </modules>
9
  <global>
app/code/local/Cartsguru/sql/cartsguru_setup/upgrade-1.2.14-1.2.15.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ /* @var $installer Mage_Core_Model_Resource_Setup */
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+ $installer->endSetup();
app/code/local/Cartsguru/sql/cartsguru_setup/upgrade-1.2.15-1.2.16.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ /* @var $installer Mage_Core_Model_Resource_Setup */
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+ $installer->endSetup();
js/cartsguru/checkout.js CHANGED
@@ -38,6 +38,7 @@
38
  var data = [];
39
  for (var item in fields) {
40
  if (fields.hasOwnProperty(item)) {
 
41
  if (item === 'email' && fields[item].value === '') {
42
  return false;
43
  }
38
  var data = [];
39
  for (var item in fields) {
40
  if (fields.hasOwnProperty(item)) {
41
+ // Only if email is set
42
  if (item === 'email' && fields[item].value === '') {
43
  return false;
44
  }
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>cartsguru</name>
4
- <version>1.2.15</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/gpl-license.php">GPL</license>
7
  <channel>community</channel>
@@ -16,11 +16,11 @@ Effortlessly reduce the number of abandoned shopping carts by automating telepho
16
  &#xD;
17
  - SMS Callback &amp; Push SMS&#xD;
18
  Send to your prospective customers having abandoned a cart, an SMS suggesting a free call back from your customer relations service, a straightforward SMS reminder or an SMS offering a personalized discount</description>
19
- <notes>- Improved cart tracking</notes>
20
  <authors><author><name>Maxime Pruvost</name><user>cgmaximepruvost</user><email>maxime@carts.guru</email></author></authors>
21
- <date>2016-11-15</date>
22
- <time>15:58:09</time>
23
- <contents><target name="magelocal"><dir name="Cartsguru"><dir name="Helper"><file name="Data.php" hash="f6590d08ba862a169ce43459ddb1193c"/><file name="Tools.php" hash="612133db113c08e7de7ab94a86d23e34"/></dir><dir name="Model"><file name="Observer.php" hash="93ad478de9ac40d76c65dd1054d9f5a5"/><file name="Webservice.php" hash="2eb173e8dee65ddf308d08bcd6e2eee2"/></dir><dir name="controllers"><file name="IndexController.php" hash="108acaab218e2a5e79a12677f83ebc29"/><file name="RecovercartController.php" hash="fab55c8774843ed11e939ee6df1ce0ed"/><file name="SaveaccountController.php" hash="6b490eca17f516a4f95bba9d4c45d30b"/></dir><dir name="etc"><file name="config.xml" hash="6f3bbe6a3fabe3e706c7fc7033913a42"/><file name="system.xml" hash="cb0fbf86d2be47dbd719739ee79c4cba"/></dir><dir name="sql"><dir name="cartsguru_setup"><file name="install-1.0.0.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.0.0-1.0.1.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.0.1-1.0.2.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.0.2-1.1.0.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.1.0-1.1.1.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.1.1-1.1.2.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.1.2-1.1.3.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.1.3-1.1.4 .php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.1.4-1.1.5.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.1.5-1.2.0.php" hash="066c5cfb9870c04737cba2d2edb30a40"/><file name="upgrade-1.2.0-1.2.1.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.2.1-1.2.2.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.2.10-1.2.11.php" hash="84cb92331d31afda4f06aca50dbd597e"/><file name="upgrade-1.2.11-1.2.12.php" hash="84cb92331d31afda4f06aca50dbd597e"/><file name="upgrade-1.2.12-1.2.13.php" hash="84cb92331d31afda4f06aca50dbd597e"/><file name="upgrade-1.2.13-1.2.14.php" hash="84cb92331d31afda4f06aca50dbd597e"/><file name="upgrade-1.2.2-1.2.3.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.2.3-1.2.4.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.2.4-1.2.5.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.2.5-1.2.6.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.2.6-1.2.7.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.2.7-1.2.8.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.2.8-1.2.9.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.2.9-1.2.10.php" hash="84cb92331d31afda4f06aca50dbd597e"/></dir></dir></dir></target><target name="magelocale"><dir name="fr_FR"><file name="CartsGuru.csv" hash="b6d51893c33ddef1d53372d3a23b036c"/></dir><dir name="en_US"><file name="CartsGuru.csv" hash="921cb4133db47471456759443bb269f5"/></dir></target><target name="mageetc"><dir name="modules"><file name="Cartsguru.xml" hash="32bfa7d63b1a5b6b8f7977bf31af4e28"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="cartsguru.xml" hash="105f906b9b304bb96b888a9afbefca66"/></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="cartsguru"><file name="checkout.js" hash="ebbb694ce1eb0e28d208cdb514ab26d3"/></dir></dir></target></contents>
24
  <compatible/>
25
  <dependencies><required><php><min>5.3.0</min><max>7.1.0</max></php></required></dependencies>
26
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>cartsguru</name>
4
+ <version>1.2.16</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/gpl-license.php">GPL</license>
7
  <channel>community</channel>
16
  &#xD;
17
  - SMS Callback &amp; Push SMS&#xD;
18
  Send to your prospective customers having abandoned a cart, an SMS suggesting a free call back from your customer relations service, a straightforward SMS reminder or an SMS offering a personalized discount</description>
19
+ <notes>- Added language, isNewCustomer and customer group into custom variables</notes>
20
  <authors><author><name>Maxime Pruvost</name><user>cgmaximepruvost</user><email>maxime@carts.guru</email></author></authors>
21
+ <date>2016-11-24</date>
22
+ <time>15:01:31</time>
23
+ <contents><target name="magelocal"><dir name="Cartsguru"><dir name="Helper"><file name="Data.php" hash="059fae47f93dda68f37c47d924e0d8a6"/><file name="Tools.php" hash="612133db113c08e7de7ab94a86d23e34"/></dir><dir name="Model"><file name="Observer.php" hash="93ad478de9ac40d76c65dd1054d9f5a5"/><file name="Webservice.php" hash="5cdbe8864004c0d68959f5964ce4b063"/></dir><dir name="controllers"><file name="IndexController.php" hash="108acaab218e2a5e79a12677f83ebc29"/><file name="RecovercartController.php" hash="fab55c8774843ed11e939ee6df1ce0ed"/><file name="SaveaccountController.php" hash="6b490eca17f516a4f95bba9d4c45d30b"/></dir><dir name="etc"><file name="config.xml" hash="aca22c0f5af04c740491c83adbe50b74"/><file name="system.xml" hash="cb0fbf86d2be47dbd719739ee79c4cba"/></dir><dir name="sql"><dir name="cartsguru_setup"><file name="install-1.0.0.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.0.0-1.0.1.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.0.1-1.0.2.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.0.2-1.1.0.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.1.0-1.1.1.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.1.1-1.1.2.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.1.2-1.1.3.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.1.3-1.1.4 .php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.1.4-1.1.5.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.1.5-1.2.0.php" hash="066c5cfb9870c04737cba2d2edb30a40"/><file name="upgrade-1.2.0-1.2.1.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.2.1-1.2.2.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.2.10-1.2.11.php" hash="84cb92331d31afda4f06aca50dbd597e"/><file name="upgrade-1.2.11-1.2.12.php" hash="84cb92331d31afda4f06aca50dbd597e"/><file name="upgrade-1.2.12-1.2.13.php" hash="84cb92331d31afda4f06aca50dbd597e"/><file name="upgrade-1.2.13-1.2.14.php" hash="84cb92331d31afda4f06aca50dbd597e"/><file name="upgrade-1.2.14-1.2.15.php" hash="c96e44a4737e1d8b0f4915c55a67c048"/><file name="upgrade-1.2.15-1.2.16.php" hash="c96e44a4737e1d8b0f4915c55a67c048"/><file name="upgrade-1.2.2-1.2.3.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.2.3-1.2.4.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.2.4-1.2.5.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.2.5-1.2.6.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.2.6-1.2.7.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.2.7-1.2.8.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.2.8-1.2.9.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.2.9-1.2.10.php" hash="84cb92331d31afda4f06aca50dbd597e"/></dir></dir></dir></target><target name="magelocale"><dir name="fr_FR"><file name="CartsGuru.csv" hash="b6d51893c33ddef1d53372d3a23b036c"/></dir><dir name="en_US"><file name="CartsGuru.csv" hash="921cb4133db47471456759443bb269f5"/></dir></target><target name="mageetc"><dir name="modules"><file name="Cartsguru.xml" hash="32bfa7d63b1a5b6b8f7977bf31af4e28"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="cartsguru.xml" hash="105f906b9b304bb96b888a9afbefca66"/></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="cartsguru"><file name="checkout.js" hash="1be2d62171ffbafe51f66dc1abc1a332"/></dir></dir></target></contents>
24
  <compatible/>
25
  <dependencies><required><php><min>5.3.0</min><max>7.1.0</max></php></required></dependencies>
26
  </package>