Retargeting_Tracker - Version 1.3.1

Version Notes

Discount Codes Bug Fixes

Download this release

Release Info

Developer Retargeting Team
Extension Retargeting_Tracker
Version 1.3.1
Comparing to
See all releases


Code changes from version 1.3.0 to 1.3.1

app/code/community/Retargeting/Tracker/controllers/DiscountsController.php CHANGED
@@ -24,10 +24,10 @@ class Retargeting_Tracker_DiscountsController extends Mage_Core_Controller_Front
24
  if ( $userApiKey != '' && $params['key'] == $userApiKey && $params['value'] != "" && $params['type'] != "" && $params['count'] != "" ) {
25
  $name = 'RA-' . htmlspecialchars($params['type']) . '-' . htmlspecialchars($params['value']);
26
  $discount = htmlspecialchars($params['value']);
27
- $type = htmlspecialchars($params['type']);
28
  $count = htmlspecialchars($params['count']);
29
 
30
- echo $this->generateRule($name, $discount, $type, $count);
31
  } else {
32
  echo json_encode(array(
33
  "status" => false,
@@ -43,24 +43,35 @@ class Retargeting_Tracker_DiscountsController extends Mage_Core_Controller_Front
43
  }
44
  }
45
 
46
- private function generateRule($name = null, $discount = 0, $type = 0, $count)
47
  {
48
  $availability = 100;
49
  $conditionAmount = 0;
50
-
51
- if ($type == 0) $type = "fixed value";
52
- if ($type == 1) $type = "percentage";
53
- if ($type == 2) $type = "free shipping";
54
 
55
- if ( $name != null && ( $type == "fixed value" || $type == "free shipping" || $type == "percentage" ) )
 
 
 
 
56
  {
 
57
  $rule = Mage::getModel('salesrule/rule');
 
58
  $customerGroupColl = Mage::getModel('customer/group')->getCollection();
59
  $customer_groups = array();
60
- foreach($customerGroupColl as $type) {
61
- $customer_groups[] = $type->getCustomerGroupId();
 
 
 
 
 
 
 
 
62
  }
63
 
 
64
  // discount name and init
65
  $rule->setName($name)
66
  ->setDescription("Autogenerated discount through Retargeting Discount API")
@@ -78,7 +89,7 @@ class Retargeting_Tracker_DiscountsController extends Mage_Core_Controller_Front
78
  ->setSimpleFreeShipping('0')
79
  ->setApplyToShipping('0')
80
  ->setIsRss(0)
81
- ->setWebsiteIds(array(1))
82
  ->setUseAutoGeneration(1);
83
 
84
  // discount code
@@ -90,7 +101,7 @@ class Retargeting_Tracker_DiscountsController extends Mage_Core_Controller_Front
90
  ->setDiscountStep(0);
91
 
92
  // discount type
93
- switch ($type) {
94
  case 'percentage':
95
  $rule->setSimpleAction('by_percent');
96
  break;
@@ -100,39 +111,13 @@ class Retargeting_Tracker_DiscountsController extends Mage_Core_Controller_Front
100
  ->setDiscountAmount(0);
101
  break;
102
  case 'fixed value':
103
- $rule->setSimpleAction('by_fixed');
104
  break;
105
  }
106
 
107
  // discount availability
108
  $rule->setFromDate(date('Y-m-d'));
109
 
110
- // discount conditions/actions
111
- /*
112
- if ($condition == "over") {
113
- $item_found = Mage::getModel('salesrule/rule_condition_product_found')
114
- ->setType('salesrule/rule_condition_product_found')
115
- ->setValue(1) // 1 == FOUND
116
- ->setAggregator('all'); // match ALL conditions
117
- $rule->getConditions()->addCondition($item_found);
118
-
119
- $conditions = Mage::getModel('salesrule/rule_condition_product')
120
- ->setType('salesrule/rule_condition_product')
121
- ->setAttribute('quote_item_price')
122
- ->setOperator('>=')
123
- ->setValue($conditionAmount);
124
- $item_found->addCondition($conditions);
125
-
126
- $actions = Mage::getModel('salesrule/rule_condition_product')
127
- ->setType('salesrule/rule_condition_product')
128
- ->setAttribute('quote_item_price')
129
- ->setOperator('>=')
130
- ->setValue($conditionAmount);
131
-
132
- $rule->getActions()->addCondition($actions);
133
- }
134
- */
135
-
136
  $generator = Mage::getModel('salesrule/coupon_massgenerator');
137
 
138
  $parameters = array(
@@ -153,7 +138,6 @@ class Retargeting_Tracker_DiscountsController extends Mage_Core_Controller_Front
153
  // Set the generator, and coupon type so it's able to generate
154
  $rule->setCouponCodeGenerator($generator);
155
 
156
-
157
  // save discount
158
  $rule->save();
159
 
@@ -169,7 +153,7 @@ class Retargeting_Tracker_DiscountsController extends Mage_Core_Controller_Front
169
 
170
  $rule->setCouponType(2);
171
  $rule->save();
172
-
173
  return json_encode($codes);
174
  }
175
 
24
  if ( $userApiKey != '' && $params['key'] == $userApiKey && $params['value'] != "" && $params['type'] != "" && $params['count'] != "" ) {
25
  $name = 'RA-' . htmlspecialchars($params['type']) . '-' . htmlspecialchars($params['value']);
26
  $discount = htmlspecialchars($params['value']);
27
+ $raDiscountType = htmlspecialchars($params['type']);
28
  $count = htmlspecialchars($params['count']);
29
 
30
+ echo $this->generateRule($name, $discount, $raDiscountType, $count);
31
  } else {
32
  echo json_encode(array(
33
  "status" => false,
43
  }
44
  }
45
 
46
+ private function generateRule($name = null, $discount = 0, $raDiscountType = 0, $count)
47
  {
48
  $availability = 100;
49
  $conditionAmount = 0;
 
 
 
 
50
 
51
+ if ($raDiscountType == 0) $raDiscountType = "fixed value";
52
+ if ($raDiscountType == 1) $raDiscountType = "percentage";
53
+ if ($raDiscountType == 2) $raDiscountType = "free shipping";
54
+
55
+ if ( $name != null && ( $raDiscountType == "fixed value" || $raDiscountType == "free shipping" || $raDiscountType == "percentage" ) )
56
  {
57
+
58
  $rule = Mage::getModel('salesrule/rule');
59
+
60
  $customerGroupColl = Mage::getModel('customer/group')->getCollection();
61
  $customer_groups = array();
62
+ foreach($customerGroupColl as $group) {
63
+ $customer_groups[] = $group->getCustomerGroupId();
64
+ }
65
+
66
+ //Get all Store Ids
67
+ $storeIds = array();
68
+ $allStores = Mage::app()->getStores();
69
+ foreach ($allStores as $storeId)
70
+ {
71
+ $storeIds[] = Mage::app()->getStore($storeId)->getId();
72
  }
73
 
74
+
75
  // discount name and init
76
  $rule->setName($name)
77
  ->setDescription("Autogenerated discount through Retargeting Discount API")
89
  ->setSimpleFreeShipping('0')
90
  ->setApplyToShipping('0')
91
  ->setIsRss(0)
92
+ ->setWebsiteIds($storeIds)
93
  ->setUseAutoGeneration(1);
94
 
95
  // discount code
101
  ->setDiscountStep(0);
102
 
103
  // discount type
104
+ switch ($raDiscountType) {
105
  case 'percentage':
106
  $rule->setSimpleAction('by_percent');
107
  break;
111
  ->setDiscountAmount(0);
112
  break;
113
  case 'fixed value':
114
+ $rule->setSimpleAction('cart_fixed');
115
  break;
116
  }
117
 
118
  // discount availability
119
  $rule->setFromDate(date('Y-m-d'));
120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  $generator = Mage::getModel('salesrule/coupon_massgenerator');
122
 
123
  $parameters = array(
138
  // Set the generator, and coupon type so it's able to generate
139
  $rule->setCouponCodeGenerator($generator);
140
 
 
141
  // save discount
142
  $rule->save();
143
 
153
 
154
  $rule->setCouponType(2);
155
  $rule->save();
156
+ header('Content-Type: application/json');
157
  return json_encode($codes);
158
  }
159
 
app/code/community/Retargeting/Tracker/etc/config.xml CHANGED
@@ -11,7 +11,7 @@
11
  <config>
12
  <modules>
13
  <Retargeting_Tracker>
14
- <version>1.2.9</version>
15
  </Retargeting_Tracker>
16
  </modules>
17
  <global>
11
  <config>
12
  <modules>
13
  <Retargeting_Tracker>
14
+ <version>1.3.1</version>
15
  </Retargeting_Tracker>
16
  </modules>
17
  <global>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Retargeting_Tracker</name>
4
- <version>1.3.0</version>
5
  <stability>stable</stability>
6
  <license>Open Software License (OSL)</license>
7
  <channel>community</channel>
@@ -27,11 +27,11 @@
27
  &lt;p&gt;You can test as many different versions as you want and you only need one click to add a new one.Did we tell you that you can do this for any trigger, e-mail or live? The perfect&lt;a href="http://en.wikipedia.org/wiki/Marketing_automation" title="marketing automation"&gt;marketing automation&lt;/a&gt;tool for your online shop!&lt;/p&gt;&#xD;
28
  &lt;p&gt;&lt;strong&gt;Contact&lt;/strong&gt;&lt;/p&gt;&#xD;
29
  &lt;p&gt;For help or more info, please contact info@retargeting.biz or visit&lt;a href="http://retargeting.biz"&gt;retargeting.biz&lt;/a&gt;.&lt;/p&gt;</description>
30
- <notes>Bug Fixes</notes>
31
  <authors><author><name>Retargeting Team</name><user>retargeting</user><email>info@retargeting.biz</email></author></authors>
32
- <date>2016-11-16</date>
33
- <time>14:33:13</time>
34
- <contents><target name="magecommunity"><dir name="Retargeting"><dir name="Tracker"><dir name="Block"><file name="Embed.php" hash="d114429b378b186d144f75b725bd36c4"/><file name="Triggers.php" hash="fd2f2fad2041280b0d0572ea0e2220de"/></dir><dir name="Helper"><file name="Data.php" hash="6b547d3d67003b8bef48fd4eb8efe23f"/></dir><dir name="Model"><file name="Helppages.php" hash="51305978cda160ad7b3aa8bb8e42d3a5"/><file name="Observer.php" hash="d41369b1ba2807567dfc857e961b7d2a"/></dir><dir name="controllers"><file name="DiscountsController.php" hash="f1ec0bbd235fcf50551ca5206dfb50e5"/><file name="IndexController.php" hash="9cbd5b979859b2014c5ed191d9b5686a"/><file name="ProductsController.php" hash="f2f556aee8c80f3a77a884792520102a"/></dir><dir name="etc"><file name="config.xml" hash="a307ab9d85f524eea26a6419874b8dba"/><file name="system.xml" hash="914aebddf7b905c7b23aeabdc4dfdcb7"/></dir><dir name="sql"><dir name="retargeting_tracker_setup"><file name="mysql4-install-1.0.0.php" hash="6613b3db4b7ec61fe47f9b69591fa0c5"/><file name="mysql4-install-1.1.0.php" hash="6613b3db4b7ec61fe47f9b69591fa0c5"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="retargeting_tracker.xml" hash="a27cb36a780ee24f3e70aba08599f37e"/></dir><dir name="template"><dir name="retargeting_tracker"><file name="embed.phtml" hash="85eae33f45d766ec21df700ae96fdb2c"/><file name="triggers.phtml" hash="8301bc699ed3c89d010ca30c15e02599"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Retargeting_Tracker.xml" hash="44dbbcea34bc8ed9cc6d744176adb9a6"/></dir></target><target name="magelib"><dir name="Retargeting"><file name="Retargeting_REST_API_Client.php" hash="fd92942d4feb817768bb8157c01c7138"/></dir></target></contents>
35
  <compatible/>
36
- <dependencies><required><php><min>5.2.0</min><max>7.2.0</max></php></required></dependencies>
37
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Retargeting_Tracker</name>
4
+ <version>1.3.1</version>
5
  <stability>stable</stability>
6
  <license>Open Software License (OSL)</license>
7
  <channel>community</channel>
27
  &lt;p&gt;You can test as many different versions as you want and you only need one click to add a new one.Did we tell you that you can do this for any trigger, e-mail or live? The perfect&lt;a href="http://en.wikipedia.org/wiki/Marketing_automation" title="marketing automation"&gt;marketing automation&lt;/a&gt;tool for your online shop!&lt;/p&gt;&#xD;
28
  &lt;p&gt;&lt;strong&gt;Contact&lt;/strong&gt;&lt;/p&gt;&#xD;
29
  &lt;p&gt;For help or more info, please contact info@retargeting.biz or visit&lt;a href="http://retargeting.biz"&gt;retargeting.biz&lt;/a&gt;.&lt;/p&gt;</description>
30
+ <notes>Discount Codes Bug Fixes</notes>
31
  <authors><author><name>Retargeting Team</name><user>retargeting</user><email>info@retargeting.biz</email></author></authors>
32
+ <date>2016-12-14</date>
33
+ <time>14:56:38</time>
34
+ <contents><target name="magecommunity"><dir name="Retargeting"><dir name="Tracker"><dir name="Block"><file name="Embed.php" hash="d114429b378b186d144f75b725bd36c4"/><file name="Triggers.php" hash="fd2f2fad2041280b0d0572ea0e2220de"/></dir><dir name="Helper"><file name="Data.php" hash="6b547d3d67003b8bef48fd4eb8efe23f"/></dir><dir name="Model"><file name="Helppages.php" hash="51305978cda160ad7b3aa8bb8e42d3a5"/><file name="Observer.php" hash="d41369b1ba2807567dfc857e961b7d2a"/></dir><dir name="controllers"><file name="DiscountsController.php" hash="1235013ee513f7f0865d87b8a8365828"/><file name="IndexController.php" hash="9cbd5b979859b2014c5ed191d9b5686a"/><file name="ProductsController.php" hash="f2f556aee8c80f3a77a884792520102a"/></dir><dir name="etc"><file name="config.xml" hash="436427b1574a492936dc2a13ea019458"/><file name="system.xml" hash="914aebddf7b905c7b23aeabdc4dfdcb7"/></dir><dir name="sql"><dir name="retargeting_tracker_setup"><file name="mysql4-install-1.0.0.php" hash="6613b3db4b7ec61fe47f9b69591fa0c5"/><file name="mysql4-install-1.1.0.php" hash="6613b3db4b7ec61fe47f9b69591fa0c5"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="retargeting_tracker.xml" hash="a27cb36a780ee24f3e70aba08599f37e"/></dir><dir name="template"><dir name="retargeting_tracker"><file name="embed.phtml" hash="85eae33f45d766ec21df700ae96fdb2c"/><file name="triggers.phtml" hash="8301bc699ed3c89d010ca30c15e02599"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Retargeting_Tracker.xml" hash="44dbbcea34bc8ed9cc6d744176adb9a6"/></dir></target><target name="magelib"><dir name="Retargeting"><file name="Retargeting_REST_API_Client.php" hash="fd92942d4feb817768bb8157c01c7138"/></dir></target></contents>
35
  <compatible/>
36
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
37
  </package>