Ometria_Magento_Extension - Version 1.1.7

Version Notes

Prevent excessive number of set-cookie headers being sent on cart and checkout pages using some payment methods.

Download this release

Release Info

Developer Alastair James
Extension Ometria_Magento_Extension
Version 1.1.7
Comparing to
See all releases


Code changes from version 1.1.6 to 1.1.7

app/code/community/Ometria/AbandonedCarts/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Ometria_AbandonedCarts>
5
- <version>1.1.6</version>
6
  </Ometria_AbandonedCarts>
7
  </modules>
8
 
2
  <config>
3
  <modules>
4
  <Ometria_AbandonedCarts>
5
+ <version>1.1.7</version>
6
  </Ometria_AbandonedCarts>
7
  </modules>
8
 
app/code/community/Ometria/Api/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Ometria_Api>
5
- <version>1.1.6</version>
6
  </Ometria_Api>
7
  </modules>
8
 
2
  <config>
3
  <modules>
4
  <Ometria_Api>
5
+ <version>1.1.7</version>
6
  </Ometria_Api>
7
  </modules>
8
 
app/code/community/Ometria/Core/Helper/Cookiechannel.php CHANGED
@@ -6,7 +6,9 @@ class Ometria_Core_Helper_Cookiechannel extends Mage_Core_Helper_Abstract {
6
  const SEPERATOR_BETWEEN_COMMANDS = ';';
7
  const SEPERATOR_IN_COMMANDS = ':';
8
 
9
- public function addCommand($command, $replace_if_exists=false){
 
 
10
  if (!$command || !is_array($command)) return;
11
 
12
  // Return if admin area or API call
@@ -18,12 +20,14 @@ class Ometria_Core_Helper_Cookiechannel extends Mage_Core_Helper_Abstract {
18
  if (!$ometria_config_helper->isConfigured()) return;
19
  if (!$ometria_config_helper->isUnivarEnabled()) return;
20
 
 
 
21
  $str = implode(self::SEPERATOR_IN_COMMANDS, $command);
22
 
23
  $this->appendCookieCommand($command[0], $str, $replace_if_exists);
24
  }
25
 
26
- private function appendCookieCommand($command_name, $str, $replace_if_exists=false){
27
  $existing_cookie = isset($_COOKIE[self::COOKIE_NAME]) ? $_COOKIE[self::COOKIE_NAME] : '';
28
  $commands = explode(self::SEPERATOR_BETWEEN_COMMANDS, $existing_cookie);
29
 
@@ -43,10 +47,26 @@ class Ometria_Core_Helper_Cookiechannel extends Mage_Core_Helper_Abstract {
43
  $commands = array_unique($commands);
44
  $commands = array_filter($commands);
45
  $commands = array_values($commands);
 
 
 
46
  $new_cookie = implode(self::SEPERATOR_BETWEEN_COMMANDS, $commands);
47
  if (strlen($new_cookie)>1000) $new_cookie = '';
48
 
49
- $_COOKIE[self::COOKIE_NAME] = $new_cookie;
50
- if (!headers_sent()) setcookie(self::COOKIE_NAME, $new_cookie, 0, '/');
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  }
52
  }
6
  const SEPERATOR_BETWEEN_COMMANDS = ';';
7
  const SEPERATOR_IN_COMMANDS = ':';
8
 
9
+ var $cookie_did_change = false;
10
+
11
+ public function addCommand($command, $replace_if_exists=false, $set_cookie=true){
12
  if (!$command || !is_array($command)) return;
13
 
14
  // Return if admin area or API call
20
  if (!$ometria_config_helper->isConfigured()) return;
21
  if (!$ometria_config_helper->isUnivarEnabled()) return;
22
 
23
+ if ($command[0]=='identify') $command[1] = '';
24
+
25
  $str = implode(self::SEPERATOR_IN_COMMANDS, $command);
26
 
27
  $this->appendCookieCommand($command[0], $str, $replace_if_exists);
28
  }
29
 
30
+ private function appendCookieCommand($command_name, $str, $replace_if_exists=false, $set_cookie=true){
31
  $existing_cookie = isset($_COOKIE[self::COOKIE_NAME]) ? $_COOKIE[self::COOKIE_NAME] : '';
32
  $commands = explode(self::SEPERATOR_BETWEEN_COMMANDS, $existing_cookie);
33
 
47
  $commands = array_unique($commands);
48
  $commands = array_filter($commands);
49
  $commands = array_values($commands);
50
+ sort($commands);
51
+ $commands = array_values($commands);
52
+
53
  $new_cookie = implode(self::SEPERATOR_BETWEEN_COMMANDS, $commands);
54
  if (strlen($new_cookie)>1000) $new_cookie = '';
55
 
56
+ if (!headers_sent() && ($new_cookie!=$existing_cookie)) {
57
+ $this->cookie_did_change = true;
58
+ $_COOKIE[self::COOKIE_NAME] = $new_cookie;
59
+ //setcookie(self::COOKIE_NAME, $new_cookie, 0, '/');
60
+ //if ($set_cookie) Mage::getModel('core/cookie')
61
+ // ->set(self::COOKIE_NAME, $new_cookie, 0, '/');
62
+ if ($set_cookie) $this->sendCookie();
63
+ }
64
+ }
65
+
66
+ public function sendCookie(){
67
+ if (!$this->cookie_did_change) return;
68
+ $cookie = isset($_COOKIE[self::COOKIE_NAME]) ? $_COOKIE[self::COOKIE_NAME] : '';
69
+ Mage::getModel('core/cookie')->set(self::COOKIE_NAME, $cookie, 0, '/');
70
+ $this->cookie_did_change = false;
71
  }
72
  }
app/code/community/Ometria/Core/Model/Observer/Cart.php CHANGED
@@ -52,16 +52,23 @@ class Ometria_Core_Model_Observer_Cart {
52
  if ($count>30) break; // Prevent overly long cookies
53
  }
54
 
55
- $ometria_cookiechannel_helper->addCommand($command, true);
56
 
57
  // Identify if needed
58
  if ($quote->getCustomerEmail()) {
59
  $identify_type = 'checkout_billing';
60
  $data = array('e'=>$quote->getCustomerEmail());
 
 
 
 
 
61
  $command = array('identify', $identify_type, http_build_query($data));
62
- $ometria_cookiechannel_helper->addCommand($command, true);
63
  }
64
 
 
 
65
  return $this;
66
  }
67
 
@@ -80,7 +87,7 @@ class Ometria_Core_Model_Observer_Cart {
80
  if ($session_id) {
81
  $ometria_ping_helper->sendPing('transaction', $order->getIncrementId(), array('session'=>$session_id), $order->store_id);
82
  }
83
- $ometria_cookiechannel_helper->addCommand(array('trans', $order->getIncrementId()));
84
 
85
  // If via front end, also identify via cookie channel (but do not replace if customer login has done it)
86
  $is_frontend = true;
@@ -99,10 +106,12 @@ class Ometria_Core_Model_Observer_Cart {
99
  }
100
 
101
  $command = array('identify', $identify_type, http_build_query($data));
102
- $ometria_cookiechannel_helper->addCommand($command, true);
103
  }
104
  } catch(Exception $e){
105
  //pass
106
  }
 
 
107
  }
108
  }
52
  if ($count>30) break; // Prevent overly long cookies
53
  }
54
 
55
+ $ometria_cookiechannel_helper->addCommand($command, true, false);
56
 
57
  // Identify if needed
58
  if ($quote->getCustomerEmail()) {
59
  $identify_type = 'checkout_billing';
60
  $data = array('e'=>$quote->getCustomerEmail());
61
+ $customer = $quote->getCustomer();
62
+ if ($customer) {
63
+ // Also set customer ID
64
+ $data['i'] = $customer->getId();
65
+ }
66
  $command = array('identify', $identify_type, http_build_query($data));
67
+ $ometria_cookiechannel_helper->addCommand($command, true, false);
68
  }
69
 
70
+ $ometria_cookiechannel_helper->sendCookie();
71
+
72
  return $this;
73
  }
74
 
87
  if ($session_id) {
88
  $ometria_ping_helper->sendPing('transaction', $order->getIncrementId(), array('session'=>$session_id), $order->store_id);
89
  }
90
+ $ometria_cookiechannel_helper->addCommand(array('trans', $order->getIncrementId()), false, false);
91
 
92
  // If via front end, also identify via cookie channel (but do not replace if customer login has done it)
93
  $is_frontend = true;
106
  }
107
 
108
  $command = array('identify', $identify_type, http_build_query($data));
109
+ $ometria_cookiechannel_helper->addCommand($command, true, false);
110
  }
111
  } catch(Exception $e){
112
  //pass
113
  }
114
+
115
+ $ometria_cookiechannel_helper->sendCookie();
116
  }
117
  }
app/code/community/Ometria/Core/Model/Observer/Newsletter.php CHANGED
@@ -37,7 +37,7 @@ class Ometria_Core_Model_Observer_Newsletter {
37
  $ometria_cookiechannel_helper = Mage::helper('ometria/cookiechannel');
38
  $data = array('e'=>$subscriber->getEmail());
39
  $command = array('identify', 'newsletter', http_build_query($data));
40
- $ometria_cookiechannel_helper->addCommand($command, false);
41
  }
42
  }
43
 
37
  $ometria_cookiechannel_helper = Mage::helper('ometria/cookiechannel');
38
  $data = array('e'=>$subscriber->getEmail());
39
  $command = array('identify', 'newsletter', http_build_query($data));
40
+ $ometria_cookiechannel_helper->addCommand($command, true);
41
  }
42
  }
43
 
app/code/community/Ometria/Core/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Ometria_Core>
5
- <version>1.1.6</version>
6
  </Ometria_Core>
7
  </modules>
8
 
2
  <config>
3
  <modules>
4
  <Ometria_Core>
5
+ <version>1.1.7</version>
6
  </Ometria_Core>
7
  </modules>
8
 
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Ometria_Magento_Extension</name>
4
- <version>1.1.6</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Source License (OSL)</license>
7
  <channel>community</channel>
@@ -21,11 +21,11 @@ Enough Data already. Tell me what to do!&#xD;
21
  We don't just pull the right data together in one place, we also create insights. Our team of data scientists have created a set of algorithms to spot weaknesses, under-performance and opportunities, so every time a retailer logs into their dashboards we present a short list of top revenue wins.&#xD;
22
  &#xD;
23
  Whether it's with our multi-dimension funnel analysis which flags up specific channels that may be under-performing, or our customer dashboard which spots channels that deliver customers with the best CLV, our 'actionable insights' come ready to go.</description>
24
- <notes>Change method of observing checkout cart updates to prevent being triggered during backend cart updates.</notes>
25
  <authors><author><name>Alastair James</name><user>aljames1981</user><email>al.james@gmail.com</email></author></authors>
26
- <date>2016-02-23</date>
27
- <time>17:40:50</time>
28
- <contents><target name="magecommunity"><dir name="Ometria"><dir name="AbandonedCarts"><dir name="Helper"><file name="Config.php" hash="4ea2f9de193a510a1438a1911f6e9a8d"/><file name="Data.php" hash="1348c35f00b49b2b30034f0d9a819ae8"/></dir><dir name="controllers"><file name="CartlinkController.php" hash="e46a511a87ca264a8df96829905545dc"/></dir><dir name="etc"><file name="config.xml" hash="f6728e5d6c41772852d80ddbea50e617"/><file name="system.xml" hash="11db59f5c2f864525e4c1cdd06283ac1"/></dir></dir><dir name="Api"><dir name="Helper"><file name="Data.php" hash="8a19a3bf39de93fab7d2e1333c3c0806"/></dir><dir name="Model"><file name="Api.php" hash="792413443cc6f22152904fb58873c27c"/><file name="Api2.php" hash="e34e5530d8e828fcdb2ce09f6abef01d"/><file name="FixedCouponGenerator.php" hash="b37f5df7471dca9437a7aed70b4c53c0"/></dir><dir name="etc"><file name="api.xml" hash="51d02f0154ac396ef90f4ff484253af3"/><file name="config.xml" hash="d24d88ea82f43aff21c49ee5c53079b2"/></dir></dir><dir name="Core"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><file name="Startwizard.php" hash="48c0cc3736f8a7fbd871d92d1aed9a81"/></dir></dir><dir name="Wizard"><file name="Finished.php" hash="3325319ce22b23c3661a15b7ab6cbb83"/><dir name="Start"><file name="Form.php" hash="e5d6f86a9718da044104245b46230674"/></dir><file name="Start.php" hash="befc4575e361b7a9916f929e2fc58c45"/></dir></dir><file name="Head.php" hash="1b00336f0bd24d46c56b6ced4c0515a6"/></dir><dir name="Helper"><file name="Config.php" hash="2d9a42f28c768aac826a590aaf571488"/><file name="Cookiechannel.php" hash="d8d7343a0e641bf59051b8ab5a06045f"/><file name="Data.php" hash="26c20107047db9e3911118efbf083135"/><file name="Ping.php" hash="d81761aa5908e3683918fac5d27742fe"/><file name="Product.php" hash="60e3b6bcb43884af7e4a4ed48c3e3411"/><file name="Session.php" hash="798245d7d20c523b3c386c8bf25979d2"/></dir><dir name="Model"><dir name="Config"><dir name="Source"><file name="Productmode.php" hash="3b37b999e8d49fc23af6229bcae86bb9"/></dir></dir><dir name="Observer"><file name="Cart.php" hash="1365cb141e1c43f9303256e1343b873a"/><file name="Customer.php" hash="c801c52474228cc56857505d38fa9db7"/><file name="Newsletter.php" hash="34a956a381ba9f5d723f49edc8cdacdf"/><file name="Order.php" hash="a93bd9b9dc73f1c48f70beee71aff7fc"/><file name="Product.php" hash="9bf6ec5b2be5103da7b1585db8cc9beb"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Test"><dir name="Config"><file name="Base.php" hash="997583679f0981fbd2f0560cf40855d1"/></dir><dir name="Model"><dir name="Observer"><file name="Order.php" hash="d4655e7789a87b3fe8093355e862bfc4"/><file name="Product.php" hash="b9d3920d0d489c39245f747f15187085"/></dir></dir></dir><dir name="controllers"><file name="WizardController.php" hash="558e829a66e2ad9a7b7c1ad9d7d4a530"/></dir><dir name="etc"><file name="config.xml" hash="96b5237e4fc5a977143571b002301377"/><file name="system.xml" hash="f494e9ed2da1f2554196847753629cb4"/></dir><file name=".DS_Store" hash="d8b910e9c4677fce43c430c2bb123061"/></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="ometria"><file name="core.xml" hash="d8d696fec5b40262b9307a0bb89bcede"/></dir></dir><dir name="template"><dir name="ometria"><file name="head.phtml" hash="1ef17e826431c85e14532d7660b38ee8"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="ometria"><file name="core.xml" hash="4fd702d8159187002eebb40c9b3ebe1b"/></dir></dir><dir name="template"><dir name="ometria"><dir name="system"><dir name="config"><file name="start_wizard.phtml" hash="d4a4e6d6ab16048f1e436793cb24a668"/></dir></dir><dir name="wizard"><file name="finished.phtml" hash="e475e0a7fb28b2b054a1b26cae5fd9b8"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Ometria_Core.xml" hash="f8ec0ef46b669bf0070d9064300fc0fd"/><file name="Ometria_Api.xml" hash="e9309a378992b51f710a9fca17a3055e"/><file name="Ometria_AbandonedCarts.xml" hash="a69a03804840e784362410c2596c0a08"/></dir></target><target name="mageweb"><dir name="js"><dir name="ometria"><file name="checkout.js" hash="78b5fed53276d65a42c5cad4bf92a35f"/></dir></dir></target></contents>
29
  <compatible/>
30
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
31
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Ometria_Magento_Extension</name>
4
+ <version>1.1.7</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Source License (OSL)</license>
7
  <channel>community</channel>
21
  We don't just pull the right data together in one place, we also create insights. Our team of data scientists have created a set of algorithms to spot weaknesses, under-performance and opportunities, so every time a retailer logs into their dashboards we present a short list of top revenue wins.&#xD;
22
  &#xD;
23
  Whether it's with our multi-dimension funnel analysis which flags up specific channels that may be under-performing, or our customer dashboard which spots channels that deliver customers with the best CLV, our 'actionable insights' come ready to go.</description>
24
+ <notes>Prevent excessive number of set-cookie headers being sent on cart and checkout pages using some payment methods.</notes>
25
  <authors><author><name>Alastair James</name><user>aljames1981</user><email>al.james@gmail.com</email></author></authors>
26
+ <date>2016-02-26</date>
27
+ <time>12:46:19</time>
28
+ <contents><target name="magecommunity"><dir name="Ometria"><dir name="AbandonedCarts"><dir name="Helper"><file name="Config.php" hash="4ea2f9de193a510a1438a1911f6e9a8d"/><file name="Data.php" hash="1348c35f00b49b2b30034f0d9a819ae8"/></dir><dir name="controllers"><file name="CartlinkController.php" hash="e46a511a87ca264a8df96829905545dc"/></dir><dir name="etc"><file name="config.xml" hash="0076fdf0d2282ed3ff0b8805bc453625"/><file name="system.xml" hash="11db59f5c2f864525e4c1cdd06283ac1"/></dir></dir><dir name="Api"><dir name="Helper"><file name="Data.php" hash="8a19a3bf39de93fab7d2e1333c3c0806"/></dir><dir name="Model"><file name="Api.php" hash="792413443cc6f22152904fb58873c27c"/><file name="Api2.php" hash="e34e5530d8e828fcdb2ce09f6abef01d"/><file name="FixedCouponGenerator.php" hash="b37f5df7471dca9437a7aed70b4c53c0"/></dir><dir name="etc"><file name="api.xml" hash="51d02f0154ac396ef90f4ff484253af3"/><file name="config.xml" hash="cc9ca68e15cbc02f9caa36a9391d110b"/></dir></dir><dir name="Core"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><file name="Startwizard.php" hash="48c0cc3736f8a7fbd871d92d1aed9a81"/></dir></dir><dir name="Wizard"><file name="Finished.php" hash="3325319ce22b23c3661a15b7ab6cbb83"/><dir name="Start"><file name="Form.php" hash="e5d6f86a9718da044104245b46230674"/></dir><file name="Start.php" hash="befc4575e361b7a9916f929e2fc58c45"/></dir></dir><file name="Head.php" hash="1b00336f0bd24d46c56b6ced4c0515a6"/></dir><dir name="Helper"><file name="Config.php" hash="2d9a42f28c768aac826a590aaf571488"/><file name="Cookiechannel.php" hash="550d4bb7ca1c0516bb7071cf3cae8e94"/><file name="Data.php" hash="26c20107047db9e3911118efbf083135"/><file name="Ping.php" hash="d81761aa5908e3683918fac5d27742fe"/><file name="Product.php" hash="60e3b6bcb43884af7e4a4ed48c3e3411"/><file name="Session.php" hash="798245d7d20c523b3c386c8bf25979d2"/></dir><dir name="Model"><dir name="Config"><dir name="Source"><file name="Productmode.php" hash="3b37b999e8d49fc23af6229bcae86bb9"/></dir></dir><dir name="Observer"><file name="Cart.php" hash="531cfab8170a72ee6c30172dc81660f3"/><file name="Customer.php" hash="c801c52474228cc56857505d38fa9db7"/><file name="Newsletter.php" hash="ea177535da561dc915fbe18889d981d7"/><file name="Order.php" hash="a93bd9b9dc73f1c48f70beee71aff7fc"/><file name="Product.php" hash="9bf6ec5b2be5103da7b1585db8cc9beb"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Test"><dir name="Config"><file name="Base.php" hash="997583679f0981fbd2f0560cf40855d1"/></dir><dir name="Model"><dir name="Observer"><file name="Order.php" hash="d4655e7789a87b3fe8093355e862bfc4"/><file name="Product.php" hash="b9d3920d0d489c39245f747f15187085"/></dir></dir></dir><dir name="controllers"><file name="WizardController.php" hash="558e829a66e2ad9a7b7c1ad9d7d4a530"/></dir><dir name="etc"><file name="config.xml" hash="31bcbdc7c3a4d297ab4f27be0b58beb8"/><file name="system.xml" hash="f494e9ed2da1f2554196847753629cb4"/></dir><file name=".DS_Store" hash="d8b910e9c4677fce43c430c2bb123061"/></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="ometria"><file name="core.xml" hash="d8d696fec5b40262b9307a0bb89bcede"/></dir></dir><dir name="template"><dir name="ometria"><file name="head.phtml" hash="1ef17e826431c85e14532d7660b38ee8"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="ometria"><file name="core.xml" hash="4fd702d8159187002eebb40c9b3ebe1b"/></dir></dir><dir name="template"><dir name="ometria"><dir name="system"><dir name="config"><file name="start_wizard.phtml" hash="d4a4e6d6ab16048f1e436793cb24a668"/></dir></dir><dir name="wizard"><file name="finished.phtml" hash="e475e0a7fb28b2b054a1b26cae5fd9b8"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Ometria_Core.xml" hash="f8ec0ef46b669bf0070d9064300fc0fd"/><file name="Ometria_Api.xml" hash="e9309a378992b51f710a9fca17a3055e"/><file name="Ometria_AbandonedCarts.xml" hash="a69a03804840e784362410c2596c0a08"/></dir></target><target name="mageweb"><dir name="js"><dir name="ometria"><file name="checkout.js" hash="78b5fed53276d65a42c5cad4bf92a35f"/></dir></dir></target></contents>
29
  <compatible/>
30
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
31
  </package>