Retargeting_Tracker - Version 1.2.7

Version Notes

Bugfixes

Download this release

Release Info

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


Code changes from version 1.2.6 to 1.2.7

app/code/community/Retargeting/Tracker/etc/config.xml CHANGED
@@ -11,7 +11,7 @@
11
  <config>
12
  <modules>
13
  <Retargeting_Tracker>
14
- <version>1.2.6</version>
15
  </Retargeting_Tracker>
16
  </modules>
17
  <global>
11
  <config>
12
  <modules>
13
  <Retargeting_Tracker>
14
+ <version>1.2.7</version>
15
  </Retargeting_Tracker>
16
  </modules>
17
  <global>
app/design/frontend/base/default/template/retargeting_tracker/embed.phtml CHANGED
@@ -24,10 +24,6 @@
24
  document.location.protocol ? "https://" : "http://") + "tracking.retargeting.biz/v3/rajs/" + ra_key + ".js";
25
  var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ra,s);})();
26
  <?php else : ?>
27
- (function(){
28
- var ra = document.createElement("script"); ra.type ="text/javascript"; ra.async = true; ra.src = ("https:" ==
29
- document.location.protocol ? "https://" : "http://") + "retargeting-data.eu/" +
30
- document.location.hostname.replace("www.","") + "/ra.js"; var s =
31
- document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ra,s);})();
32
  <?php endif; ?>
33
  </script>
24
  document.location.protocol ? "https://" : "http://") + "tracking.retargeting.biz/v3/rajs/" + ra_key + ".js";
25
  var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ra,s);})();
26
  <?php else : ?>
27
+ console.info('ra_key is not set.');
 
 
 
 
28
  <?php endif; ?>
29
  </script>
app/design/frontend/base/default/template/retargeting_tracker/triggers.phtml CHANGED
@@ -7,1008 +7,1049 @@
7
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
  */
9
  ?>
10
- <?php
11
  /**
12
- * Retargeting Triggers code
13
- **/
14
  ?>
15
  <?php $magentoVersion = Mage::getVersion(); ?>
16
 
17
- <?php if ( Mage::app()->getFrontController()->getRequest()->getControllerName() == "product" && !is_null(Mage::registry('product')) ) : ?>
18
- <script>
19
- // Retargeting JS helpers
20
- function _ra_helper_addLoadEvent(func) {
21
- var oldonload = window.onload;
22
- if (typeof window.onload != 'function') {
23
- window.onload = func;
24
- } else {
25
- window.onload = function() {
26
- if (oldonload) {
27
- oldonload();
28
- }
29
- func();
30
- }
31
- }
32
- }
33
- </script>
34
  <?php endif ?>
35
 
36
  <script>
37
- <?php
38
- /*
39
- ----------------------- Trigger setEmail -----------------------
40
- */
41
- ?>
42
- <?php if ( $info = Mage::getSingleton('core/session')->getTriggerSetEmail() ) : ?>
43
- // Trigger setEmail
44
- var _ra = _ra || {};
45
- _ra.setEmailInfo = {
46
- "email": "<?php echo htmlspecialchars($info['email']); ?>",
47
- "name": "<?php echo htmlspecialchars($info['name']); ?>",
48
- "phone": "<?php echo htmlspecialchars($info['phone']); ?>",
49
- "city": "<?php echo htmlspecialchars($info['city']); ?>",
50
- "sex": "<?php echo htmlspecialchars($info['sex']); ?>"
51
- };
52
- if (_ra.ready !== undefined) {
53
- if(typeof _ra.setEmail !== "undefined") _ra.setEmail(_ra.setEmailInfo);
54
- }
55
- <?php Mage::getSingleton('core/session')->unsTriggerSetEmail(); ?>
56
- <?php endif ?>
57
- <?php
58
- /*
59
- ----------------------- Trigger sendCategory -----------------------
60
- */
61
- ?>
62
- <?php if ( Mage::app()->getFrontController()->getRequest()->getControllerName() == "category" ) : ?>
63
-
64
- // Trigger sendCategory
65
-
66
- <?php $_category = Mage::registry('current_category'); ?>
67
- <?php
68
- $_categoryParent = "false";
69
- $_categoryBreadcrumb = "[]";
70
- if ( $_category->getLevel() > 2 ) {
71
- $_categoryParent = '"'.$_category->getParentId().'"';
72
- $_categoryBreadcrumb = array();
73
- $breadcrumbCategory = $_category;
74
- while ( $breadcrumbCategory->getLevel() > 2 ) {
75
- $breadcrumbCategory = Mage::getModel('catalog/category')->load($breadcrumbCategory->getParentId());
76
-
77
- $_categoryBreadcrumb[] = '[{
78
- "id": "'.$breadcrumbCategory->getId().'",
79
- "name": "'.htmlspecialchars($breadcrumbCategory->getName()).'",
80
- "parent": '.( $breadcrumbCategory->getLevel() > 2 ? '"'.$breadcrumbCategory->getParentId().'"' : 'false' ).'
 
 
81
  }]';
82
- }
83
- $_categoryBreadcrumb = '['.implode(', ', $_categoryBreadcrumb).']';
84
- }
85
- ?>
86
-
87
- var _ra = _ra || {};
88
- _ra.sendCategoryInfo = {
89
- "id": "<?php echo $_category->getId(); ?>",
90
- "name": "<?php echo htmlspecialchars($_category->getName()); ?>",
91
- "parent": <?php echo $_categoryParent; ?>,
92
- "breadcrumb": <?php echo $_categoryBreadcrumb; ?>
93
- };
94
-
95
- if (_ra.ready !== undefined) {
96
- if(typeof _ra.sendCategory !== "undefined") _ra.sendCategory(_ra.sendCategoryInfo);
97
- }
98
 
99
- <?php endif ?>
100
- <?php
101
- /*
102
- ----------------------- Trigger sendBrand -----------------------
103
- magento doesn't have core support for brands..
104
- */
105
- ?>
106
- <?php
107
- /*
108
- ----------------------- Trigger sendProduct -----------------------
109
- */
110
- ?>
111
- <?php if ( Mage::app()->getFrontController()->getRequest()->getControllerName() == "product" && !is_null(Mage::registry('product')) ) : ?>
112
-
113
- // Trigger sendProduct
114
-
115
- <?php $_product = Mage::registry('current_product'); ?>
116
-
117
- <?php if($_product) : ?>
118
- <?php
119
- $_productUrl = Mage::helper('core/url')->getCurrentUrl();
120
-
121
- $_category = false;
122
- if ( Mage::registry('current_category') ) {
123
- $_category = Mage::registry('current_category');
124
- } else {
125
- $_productCategoryIds = $_product->getCategoryIds();
126
- if ( count($_productCategoryIds) ) {
127
- $firstCategoryId = $_productCategoryIds[0];
128
- $_category = Mage::getModel('catalog/category')->load($firstCategoryId);
129
- }
130
- }
131
-
132
- $_categoryParent = "false";
133
- $_categoryBreadcrumb = "[]";
134
-
135
- if($_category) {
136
- if ( $_category->getLevel() > 2 ) {
137
- $_categoryParent = '"'.$_category->getParentId().'"';
138
- $_categoryBreadcrumb = array();
139
- $breadcrumbCategory = $_category;
140
- while ( $breadcrumbCategory->getLevel() > 2 ) {
141
- $breadcrumbCategory = Mage::getModel('catalog/category')->load($breadcrumbCategory->getParentId());
142
- $_categoryBreadcrumb[] = '{
143
- "id": "'.$breadcrumbCategory->getId().'",
144
- "name": "'.htmlspecialchars($breadcrumbCategory->getName()).'",
145
- "parent": '.( $breadcrumbCategory->getLevel() > 2 ? '"'.$breadcrumbCategory->getParentId().'"' : 'false' ).'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  }';
147
- }
148
- $_categoryBreadcrumb = '['.implode(', ', $_categoryBreadcrumb).']';
149
- }
150
- $_category = '[{
151
- "id": "'.$_category->getId().'",
152
- "name": "'.htmlspecialchars($_category->getName()).'",
153
- "parent": '.$_categoryParent.',
154
- "breadcrumb" : '.$_categoryBreadcrumb.
155
- '}]';
156
- } else {
157
- $_category = '[{
158
  "id": "-1",
159
  "name": "no category",
160
  "parent": false
161
  }]';
162
- }
163
- ?>
164
-
165
- var _ra = _ra || {};
166
- _ra.sendProductInfo = {
167
- "id": "<?php echo $_product->getId(); ?>",
168
- "name": "<?php echo htmlspecialchars($_product->getName()); ?>",
169
- "url": "<?php echo htmlspecialchars(strtok($_productUrl,'?')); ?>",
170
- "img": "<?php echo htmlspecialchars( Mage::helper('catalog/image')->init($_product, 'image')->resize(500) ); ?>",
171
- "price": <?php echo Mage::helper('tax')->getPrice($_product, $_product->getPrice()); ?>,
172
- "promo": <?php echo ( Mage::helper('tax')->getPrice($_product, $_product->getPrice()) - Mage::helper('tax')->getPrice($_product, $_product->getFinalPrice()) > 0 ? Mage::helper('tax')->getPrice($_product, $_product->getFinalPrice()) : 0 ); ?>,
173
- "inventory": {
174
- "variations": false,
175
- "stock": <?php echo $_product->getIsInStock() ?>
176
- },
177
- "brand": false,
178
- "category": <?php echo $_category; ?>
179
- };
180
-
181
- if (_ra.ready !== undefined) {
182
- if(typeof _ra.sendProduct !== "undefined") _ra.sendProduct(_ra.sendProductInfo);
183
- }
184
- <?php endif ?>
185
- <?php endif ?>
186
- <?php
187
- /*
188
- ----------------------- Trigger addToCart -----------------------
189
- */
190
- ?>
191
- <?php if ( $info = Mage::getSingleton('core/session')->getTriggerAddToCart() ) : ?>
192
-
193
- // Trigger addToCart
194
-
195
- <?php $referral = Mage::getSingleton('core/session')->getReferralController(); echo "/*".$referral."*/"; ?>
196
- <?php if ( $referral != "product" ) : ?>
197
-
198
- // Trigger sendProduct before addToCart
199
-
200
- <?php
201
- $_product = Mage::getModel('catalog/product')->load($info['product_id']);
202
- $_productUrl = $_product->getProductUrl();
203
- $_category = false;
204
-
205
- $_productCategoryIds = $_product->getCategoryIds();
206
- if ( count($_productCategoryIds) ) {
207
- $firstCategoryId = $_productCategoryIds[0];
208
- $_category = Mage::getModel('catalog/category')->load($firstCategoryId);
209
- }
210
-
211
- $_categoryParent = "false";
212
- $_categoryBreadcrumb = "[]";
213
-
214
- if($_category) {
215
- if ( $_category->getLevel() > 2 ) {
216
- $_categoryParent = '"'.$_category->getParentId().'"';
217
- $_categoryBreadcrumb = array();
218
- $breadcrumbCategory = $_category;
219
- while ( $breadcrumbCategory->getLevel() > 2 ) {
220
- $breadcrumbCategory = Mage::getModel('catalog/category')->load($breadcrumbCategory->getParentId());
221
-
222
- $_categoryBreadcrumb[] = '{
223
- "id": "'.$breadcrumbCategory->getId().'",
224
- "name": "'.htmlspecialchars($breadcrumbCategory->getName()).'",
225
- "parent": '.( $breadcrumbCategory->getLevel() > 2 ? '"'.$breadcrumbCategory->getParentId().'"' : 'false' ).'
226
- }';
227
- }
228
- $_categoryBreadcrumb = '['.implode(', ', $_categoryBreadcrumb).']';
229
- }
230
- $_category = '[{
231
- "id": "'.$_category->getId().'",
232
- "name": "'.htmlspecialchars($_category->getName()).'",
233
- "parent": '.$_categoryParent.',
234
- "breadcrumb" : '.$_categoryBreadcrumb.
235
- '}]';
236
- } else {
237
- $_category = '[{"id": "-1", "name": "no category", "parent": false}]';
238
- }
239
- ?>
240
-
241
- var _ra = _ra || {};
242
- _ra.sendProductInfo = {
243
- "id": "<?php echo $_product->getId(); ?>",
244
- "name": "<?php echo htmlspecialchars($_product->getName()); ?>",
245
- "url": "<?php echo htmlspecialchars(strtok($_productUrl,'?')); ?>",
246
- "img": "<?php echo htmlspecialchars( Mage::helper('catalog/image')->init($_product, 'image')->resize(500) ); ?>",
247
- "price": <?php echo Mage::helper('tax')->getPrice($_product, $_product->getPrice()); ?>,
248
- "promo": <?php echo ( Mage::helper('tax')->getPrice($_product, $_product->getPrice()) - Mage::helper('tax')->getPrice($_product, $_product->getFinalPrice()) > 0 ? Mage::helper('tax')->getPrice($_product, $_product->getFinalPrice()) : 0 ); ?>,
249
- "inventory": {
250
- "variations": false,
251
- "stock": <?php echo $_product->getIsInStock() ?>
252
- },
253
- "brand": false,
254
- "category": <?php echo $_category; ?>,
255
- "callback_function": function() {
256
- _ra.addToCartInfo = {
257
- "product_id": "<?php echo $info['product_id']; ?>",
258
- "quantity": <?php echo $_product->getIsInStock() ?>,
259
- "variation": <?php echo $info['variation']; ?>
260
- };
261
- if(typeof _ra.addToCart !== "undefined") _ra.addToCart(_ra.addToCartInfo.product_id, _ra.addToCartInfo.variation);
262
- }
263
- };
264
-
265
- if (_ra.ready !== undefined) {
266
- if(typeof _ra.sendProduct !== "undefined") _ra.sendProduct(_ra.sendProductInfo);
267
- }
268
-
269
- <?php else : ?>
270
-
271
- var _ra = _ra || {};
272
- _ra.addToCartInfo = {
273
- "product_id": "<?php echo $info['product_id']; ?>",
274
- "quantity": 1,
275
- "variation": <?php echo $info['variation']; ?>
276
- };
277
-
278
- if (_ra.ready !== undefined) {
279
- if(typeof _ra.addToCart !== "undefined") _ra.addToCart(_ra.addToCartInfo.product_id, _ra.addToCartInfo.variation);
280
- }
281
-
282
- <?php endif ?>
283
-
284
- <?php Mage::getSingleton('core/session')->unsTriggerAddToCart(); ?>
285
- <?php endif ?>
286
- <?php
287
- /*
288
- ----------------------- Trigger setVariation -----------------------
289
- */
290
- if($magentoVersion > "1.4.2.0") :
291
- ?>
292
- <?php if ( Mage::app()->getFrontController()->getRequest()->getControllerName() == "product" && !is_null(Mage::registry('product')) ) : ?>
293
-
294
- // Trigger setVariation
295
-
296
- <?php $_product = Mage::registry('current_product'); ?>
297
- <?php if ($_product) : ?>
298
-
299
- <?php if ( !$_product->isConfigurable() ) : ?>
300
- <?php /*is not configurable*/ ?>
301
- <?php if ( $_product->getTypeInstance(true)->hasOptions($_product) ) : ?>
302
-
303
- function _ra_triggerSetVariation() {
304
- var _ra_variation = _ra_grabVariation();
305
- if(typeof _ra.setVariation !== "undefined") _ra.setVariation("<?php echo $_product->getId(); ?>", _ra_variation);
306
- }
307
-
308
- _ra_optElfunc = [];
309
- function _ra_grabVariation() {
310
- var _ra_vo = {};
311
- var _ra_voCode = [];
312
- var _ra_voDetails = {};
313
- <?php foreach ( $_product->getOptions() as $o ) : ?>
314
- <?php $optionType = $o->getType(); ?>
315
- <?php $optionId = $o->getId(); ?>
316
- <?php $optionTitle = $o->getTitle(); ?>
317
-
318
- <?php if ( $optionType == "area" ) : ?>
319
- if ( document.querySelector(".product-custom-option[name='options[<?php echo $optionId; ?>]']") !== null ) {
320
- _ra_voCode.push(document.querySelector(".product-custom-option[name='options[<?php echo $optionId; ?>]']").value);
321
- }
322
- <?php endif ?>
323
-
324
- <?php if ( $optionType == "field" ) : ?>
325
- if ( document.querySelector(".product-custom-option[name='options[<?php echo $optionId; ?>]']") !== null ) {
326
- _ra_voCode.push(document.querySelector(".product-custom-option[name='options[<?php echo $optionId; ?>]']").value);
327
- }
328
- <?php endif ?>
329
-
330
- <?php if ( $optionType == "checkbox" ) : ?>
331
- if ( document.querySelectorAll("input[type='checkbox'].product-custom-option[name='options[<?php echo $optionId; ?>][]']").length > 0 ) {
332
- var _ra_optionValue = [];
333
- var _ra_arr = document.querySelectorAll("input[type='checkbox'].product-custom-option[name='options[<?php echo $optionId; ?>][]']");
334
- for( var index = 0; index < _ra_arr.length; index ++ ) {
335
- if(_ra_arr[index].checked) {
336
- _ra_optionValue.push(document.querySelector("label[for='"+_ra_arr[index].getAttribute('id')+"']").innerText);
337
- }
338
- }
339
- _ra_voCode.push(_ra_optionValue.join(', '));
340
- }
341
- <?php endif ?>
342
-
343
- <?php if ( $optionType == "date" ) : ?>
344
- if ( document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']") !== null ) {
345
- var _ra_optionValue = [];
346
- _ra_optionValue.push(document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']").options[document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']").selectedIndex].text);
347
- _ra_optionValue.push(document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']").options[document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']").selectedIndex].text);
348
- _ra_optionValue.push(document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']").options[document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']").selectedIndex].text);
349
- _ra_voCode.push(_ra_optionValue.join('/'));
350
- }
351
- <?php endif ?>
352
-
353
- <?php if ( $optionType == "date_time" ) : ?>
354
- if ( document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']") !== null ) {
355
- var _ra_optionValue = [];
356
- _ra_optionValue.push(document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']").options[document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']").selectedIndex].text);
357
- _ra_optionValue.push(document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']").options[document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']").selectedIndex].text);
358
- _ra_optionValue.push(document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']").options[document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']").selectedIndex].text);
359
- _ra_optionValue.push(document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']").options[document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']").selectedIndex].text);
360
- _ra_optionValue.push(document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']").options[document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']").selectedIndex].text);
361
- _ra_optionValue.push(document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']").options[document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']").selectedIndex].text);
362
- _ra_voCode.push(_ra_optionValue.join('/'));
363
- }
364
- <?php endif ?>
365
-
366
- <?php if ( $optionType == "drop_down" ) : ?>
367
- if ( document.querySelector("select.product-custom-option[name='options[<?php echo $optionId; ?>]']") !== null ) {
368
- _ra_voCode.push(document.querySelector("select.product-custom-option[name='options[<?php echo $optionId; ?>]']").options[document.querySelector("select.product-custom-option[name='options[<?php echo $optionId; ?>]']").selectedIndex].text);
369
- }
370
- <?php endif ?>
371
- <?php if ( $optionType == "multiple" ) : ?>
372
- if ( document.querySelector("select.multiselect.product-custom-option[name='options[<?php echo $optionId; ?>][]']") !== null ) {
373
- var _ra_optionValue = [];
374
- var _ra_arr = document.querySelector("select.multiselect.product-custom-option[name='options[<?php echo $optionId; ?>][]']").options;
375
- for ( var index = 0; index < _ra_arr.length; index ++ ) {
376
- if ( _ra_arr[index].selected ) _ra_optionValue.push(_ra_arr[index].text);
377
- }
378
- _ra_voCode.push(_ra_optionValue.join('_'));
379
- }
380
- <?php endif ?>
381
-
382
- <?php if ( $optionType == "radio" ) : ?>
383
- if ( document.querySelectorAll("input[type='radio'].product-custom-option[name='options[<?php echo $optionId; ?>]']").length > 0 ) {
384
- var _ra_optionValue = [];
385
- var _ra_arr = document.querySelectorAll("input[type='radio'].product-custom-option[name='options[<?php echo $optionId; ?>]']");
386
- for( var index = 0; index < _ra_arr.length; index ++ ) {
387
- if(_ra_arr[index].checked) {
388
- _ra_optionValue.push(document.querySelector("label[for='"+_ra_arr[index].getAttribute('id')+"']").innerText);
389
- }
390
- }
391
- _ra_voCode.push(_ra_optionValue.join(', '));
392
- }
393
- <?php endif ?>
394
- <?php if ( $optionType == "time" ) : ?>
395
- if ( document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']") !== null ) {
396
- var _ra_optionValue = [];
397
- _ra_optionValue.push(document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']").options[document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']").selectedIndex].text);
398
- _ra_optionValue.push(document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']").options[document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']").selectedIndex].text);
399
- _ra_optionValue.push(document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']").options[document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']").selectedIndex].text);
400
- _ra_voCode.push(_ra_optionValue.join('/'));
401
- }
402
- <?php endif ?>
403
-
404
- <?php if ( $optionType == "file" ) : ?>
405
- if ( document.querySelector("input[type='file'].product-custom-option[name='options_<?php echo $optionId; ?>_file']") !== null ) {
406
- _ra_voCode.push(document.querySelector("input[type='file'].product-custom-option[name='options_<?php echo $optionId; ?>_file']").value.split(/(\\|\/)/g).pop());
407
- }
408
- <?php endif ?>
409
-
410
- _ra_voDetails[_ra_voCode[_ra_voCode.length - 1].replace(RegExp("[- ]", 'g'), '')] = {
411
- "category_name": "<?php echo $optionTitle; ?>",
412
- "category": "<?php echo $optionTitle; ?>",
413
- "value": _ra_voCode[_ra_voCode.length - 1]
414
- };
415
- _ra_voCode[_ra_voCode.length - 1] = _ra_voCode[_ra_voCode.length - 1].replace(RegExp("[- ]", 'g'), '');
416
-
417
- <?php endforeach ?>
418
-
419
- var _ra_vo = {
420
- "code": _ra_voCode.join('-'),
421
- "details": _ra_voDetails
422
- }
423
- return _ra_vo;
424
- }
425
- _ra_helper_addLoadEvent(function() {
426
- <?php foreach ( $_product->getOptions() as $o ) : ?>
427
- <?php $optionType = $o->getType(); ?>
428
- <?php $optionId = $o->getId(); ?>
429
-
430
- <?php if ( $optionType == "area" ) : ?>
431
- if ( document.querySelector(".product-custom-option[name='options[<?php echo $optionId; ?>]']") !== null ) {
432
- _ra_optElfunc[<?php echo $optionId; ?>] = document.querySelector(".product-custom-option[name='options[<?php echo $optionId; ?>]']").onchange;
433
- document.querySelector(".product-custom-option[name='options[<?php echo $optionId; ?>]']").onchange = function() {
434
- if ( _ra_optElfunc[<?php echo $optionId; ?>] !== null ) _ra_optElfunc[<?php echo $optionId; ?>]();
435
- _ra_triggerSetVariation();
436
- }
437
- }
438
- <?php endif ?>
439
-
440
- <?php if ( $optionType == "field" ) : ?>
441
- if ( document.querySelector(".product-custom-option[name='options[<?php echo $optionId; ?>]']") !== null ) {
442
- _ra_optElfunc[<?php echo $optionId; ?>] = document.querySelector(".product-custom-option[name='options[<?php echo $optionId; ?>]']").onchange;
443
- document.querySelector(".product-custom-option[name='options[<?php echo $optionId; ?>]']").onchange = function() {
444
- if ( _ra_optElfunc[<?php echo $optionId; ?>] !== null ) _ra_optElfunc[<?php echo $optionId; ?>]();
445
- _ra_triggerSetVariation();
446
- }
447
- }
448
- <?php endif ?>
449
-
450
- <?php if ( $optionType == "checkbox" ) : ?>
451
- if ( document.querySelectorAll("input[type='checkbox'].product-custom-option[name='options[<?php echo $optionId; ?>][]']").length > 0 ) {
452
- _ra_optElfunc[<?php echo $optionId; ?>] = [];
453
- for ( var index = 0; index < document.querySelectorAll("input[type='checkbox'].product-custom-option[name='options[<?php echo $optionId; ?>][]']").length; index ++ ) {
454
- _ra_optElfunc[document.querySelectorAll("input[type='checkbox'].product-custom-option[name='options[<?php echo $optionId; ?>][]']")[index]] = document.querySelectorAll("input[type='checkbox'].product-custom-option[name='options[<?php echo $optionId; ?>][]']")[index].onclick;
455
- document.querySelectorAll("input[type='checkbox'].product-custom-option[name='options[<?php echo $optionId; ?>][]']")[index].onclick = function() {
456
- if ( _ra_optElfunc[this] !== null ) _ra_optElfunc[this]();
457
- _ra_triggerSetVariation();
458
- }
459
- }
460
- }
461
- <?php endif ?>
462
-
463
- <?php if ( $optionType == "date" ) : ?>
464
- if ( document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']") !== null ) {
465
- _ra_optElfunc[<?php echo $optionId; ?>] = [];
466
- _ra_optElfunc[<?php echo $optionId; ?>][0] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']").onchange;
467
- _ra_optElfunc[<?php echo $optionId; ?>][1] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']").onchange;
468
- _ra_optElfunc[<?php echo $optionId; ?>][2] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']").onchange;
469
- document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']").onchange = function() {
470
- if ( _ra_optElfunc[<?php echo $optionId; ?>][0] !== null ) _ra_optElfunc[<?php echo $optionId; ?>][0]();
471
- _ra_triggerSetVariation();
472
- }
473
- document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']").onchange = function() {
474
- if ( _ra_optElfunc[<?php echo $optionId; ?>][1] !== null ) _ra_optElfunc[<?php echo $optionId; ?>][1]();
475
- _ra_triggerSetVariation();
476
- }
477
- document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']").onchange = function() {
478
- if ( _ra_optElfunc[<?php echo $optionId; ?>][2] !== null ) _ra_optElfunc[<?php echo $optionId; ?>][2]();
479
- _ra_triggerSetVariation();
480
- }
481
- }
482
- <?php endif ?>
483
-
484
- <?php if ( $optionType == "date_time" ) : ?>
485
- if ( document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']") !== null ) {
486
- _ra_optElfunc[<?php echo $optionId; ?>] = [];
487
- _ra_optElfunc[<?php echo $optionId; ?>][0] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']").onchange;
488
- _ra_optElfunc[<?php echo $optionId; ?>][1] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']").onchange;
489
- _ra_optElfunc[<?php echo $optionId; ?>][2] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']").onchange;
490
- _ra_optElfunc[<?php echo $optionId; ?>][3] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']").onchange;
491
- _ra_optElfunc[<?php echo $optionId; ?>][4] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']").onchange;
492
- _ra_optElfunc[<?php echo $optionId; ?>][5] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']").onchange;
493
- document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']").onchange = function() {
494
- if ( _ra_optElfunc[<?php echo $optionId; ?>][0] !== null ) _ra_optElfunc[<?php echo $optionId; ?>][0]();
495
- _ra_triggerSetVariation();
496
- }
497
- document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']").onchange = function() {
498
- if ( _ra_optElfunc[<?php echo $optionId; ?>][1] !== null ) _ra_optElfunc[<?php echo $optionId; ?>][1]();
499
- _ra_triggerSetVariation();
500
- }
501
- document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']").onchange = function() {
502
- if ( _ra_optElfunc[<?php echo $optionId; ?>][2] !== null ) _ra_optElfunc[<?php echo $optionId; ?>][2]();
503
- _ra_triggerSetVariation();
504
- }
505
- document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']").onchange = function() {
506
- if ( _ra_optElfunc[<?php echo $optionId; ?>][3] !== null ) _ra_optElfunc[<?php echo $optionId; ?>][3]();
507
- _ra_triggerSetVariation();
508
- }
509
- document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']").onchange = function() {
510
- if ( _ra_optElfunc[<?php echo $optionId; ?>][4] !== null ) _ra_optElfunc[<?php echo $optionId; ?>][4]();
511
- _ra_triggerSetVariation();
512
- }
513
- document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']").onchange = function() {
514
- if ( _ra_optElfunc[<?php echo $optionId; ?>][5] !== null ) _ra_optElfunc[<?php echo $optionId; ?>][5]();
515
- _ra_triggerSetVariation();
516
- }
517
- }
518
- <?php endif ?>
519
-
520
- <?php if ( $optionType == "drop_down" ) : ?>
521
- if ( document.querySelector("select.product-custom-option[name='options[<?php echo $optionId; ?>]']") !== null ) {
522
- _ra_optElfunc[<?php echo $optionId; ?>] = document.querySelector("select.product-custom-option[name='options[<?php echo $optionId; ?>]']").onchange;
523
- document.querySelector("select.product-custom-option[name='options[<?php echo $optionId; ?>]']").onchange = function() {
524
- if ( _ra_optElfunc[<?php echo $optionId; ?>] !== null ) _ra_optElfunc[<?php echo $optionId; ?>]();
525
- _ra_triggerSetVariation();
526
- }
527
- }
528
- <?php endif ?>
529
-
530
- <?php if ( $optionType == "multiple" ) : ?>
531
- if ( document.querySelector("select.multiselect.product-custom-option[name='options[<?php echo $optionId; ?>][]']") !== null ) {
532
- _ra_optElfunc[<?php echo $optionId; ?>] = document.querySelector("select.multiselect.product-custom-option[name='options[<?php echo $optionId; ?>][]']").onchange;
533
- document.querySelector("select.multiselect.product-custom-option[name='options[<?php echo $optionId; ?>][]']").onchange = function() {
534
- if ( _ra_optElfunc[<?php echo $optionId; ?>] !== null ) _ra_optElfunc[<?php echo $optionId; ?>]();
535
- _ra_triggerSetVariation();
536
- }
537
- }
538
- <?php endif ?>
539
-
540
- <?php if ( $optionType == "radio" ) : ?>
541
- if ( document.querySelectorAll("input[type='radio'].product-custom-option[name='options[<?php echo $optionId; ?>]']").length > 0 ) {
542
- _ra_optElfunc[<?php echo $optionId; ?>] = [];
543
- for ( var index = 0; index < document.querySelectorAll("input[type='radio'].product-custom-option[name='options[<?php echo $optionId; ?>]']").length; index ++ ) {
544
- _ra_optElfunc[document.querySelectorAll("input[type='radio'].product-custom-option[name='options[<?php echo $optionId; ?>]']")[index]] = document.querySelectorAll("input[type='radio'].product-custom-option[name='options[<?php echo $optionId; ?>]']")[index].onclick;
545
- document.querySelectorAll("input[type='radio'].product-custom-option[name='options[<?php echo $optionId; ?>]']")[index].onclick = function() {
546
- if ( _ra_optElfunc[this] !== null ) _ra_optElfunc[this]();
547
- _ra_triggerSetVariation();
548
- }
549
- }
550
- }
551
- <?php endif ?>
552
-
553
- <?php if ( $optionType == "time" ) : ?>
554
- if ( document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']") !== null ) {
555
- _ra_optElfunc[<?php echo $optionId; ?>] = [];
556
- _ra_optElfunc[<?php echo $optionId; ?>][0] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']").onchange;
557
- _ra_optElfunc[<?php echo $optionId; ?>][1] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']").onchange;
558
- _ra_optElfunc[<?php echo $optionId; ?>][2] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']").onchange;
559
- document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']").onchange = function() {
560
- if ( _ra_optElfunc[<?php echo $optionId; ?>][0] !== null ) _ra_optElfunc[<?php echo $optionId; ?>][0]();
561
- _ra_triggerSetVariation();
562
- }
563
- document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']").onchange = function() {
564
- if ( _ra_optElfunc[<?php echo $optionId; ?>][1] !== null ) _ra_optElfunc[<?php echo $optionId; ?>][1]();
565
- _ra_triggerSetVariation();
566
- }
567
- document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']").onchange = function() {
568
- if ( _ra_optElfunc[<?php echo $optionId; ?>][2] !== null ) _ra_optElfunc[<?php echo $optionId; ?>][2]();
569
- _ra_triggerSetVariation();
570
- }
571
- }
572
- <?php endif ?>
573
-
574
- <?php if ( $optionType == "file" ) : ?>
575
- if ( document.querySelector("input[type='file'].product-custom-option[name='options_<?php echo $optionId; ?>_file']") !== null ) {
576
- _ra_optElfunc[<?php echo $optionId; ?>] = document.querySelector("input[type='file'].product-custom-option[name='options_<?php echo $optionId; ?>_file']").onchange;
577
- document.querySelector("input[type='file'].product-custom-option[name='options_<?php echo $optionId; ?>_file']").onchange = function() {
578
- if ( _ra_optElfunc[<?php echo $optionId; ?>] !== null ) _ra_optElfunc[<?php echo $optionId; ?>]();
579
- _ra_triggerSetVariation();
580
- }
581
- }
582
- <?php endif ?>
583
-
584
- <?php endforeach ?>
585
- });
586
- <?php endif ?>
587
-
588
-
589
-
590
- <?php /*is not configurable*/ ?>
591
- <?php else : ?>
592
- <?php /*is configurable*/ ?>
593
- /*configurable product..*/
594
- <?php $_productAttributeOptions = $_product->getTypeInstance(true)->getConfigurableAttributesAsArray($_product); ?>
595
- <?php if ( count( $_productAttributeOptions ) > 0 ) : ?>
596
-
597
- function _ra_triggerSetVariation() {
598
- var _ra_variation = _ra_grabVariation();
599
- if(typeof _ra.setVariation !== "undefined") _ra.setVariation("<?php echo $_product->getId(); ?>", _ra_variation);
600
- }
601
-
602
- _ra_optElfunc = [];
603
-
604
- function _ra_grabVariation() {
605
- var _ra_vo = {};
606
- var _ra_voCode = [];
607
- var _ra_voDetails = {};
608
-
609
- <?php foreach ($_productAttributeOptions as $_productAttribute) : ?>
610
- <?php $attributeId = $_productAttribute["attribute_id"]; ?>
611
- <?php $attributeTitle = $_productAttribute["label"]; ?>
612
- if ( document.getElementById("attribute<?php echo $attributeId; ?>") !== null ) {
613
- _ra_voCode.push(document.getElementById("attribute<?php echo $attributeId; ?>").options[document.getElementById("attribute<?php echo $attributeId; ?>").selectedIndex].text);
614
- }
615
- _ra_voDetails[_ra_voCode[_ra_voCode.length - 1].replace(RegExp("[- ]", 'g'), '')] = {
616
- "category_name": "<?php echo $attributeTitle; ?>",
617
- "category": "<?php echo $attributeTitle; ?>",
618
- "value": _ra_voCode[_ra_voCode.length - 1]
619
- };
620
- _ra_voCode[_ra_voCode.length - 1] = _ra_voCode[_ra_voCode.length - 1].replace(RegExp("[- ]", 'g'), '');
621
- <?php endforeach ?>
622
-
623
- var _ra_vo = {
624
- "code": _ra_voCode.join('-'),
625
- "details": _ra_voDetails
626
- }
627
-
628
- return _ra_vo;
629
- }
630
-
631
- _ra_helper_addLoadEvent(function() {
632
- <?php foreach ($_productAttributeOptions as $_productAttribute) : ?>
633
- <?php $attributeId = $_productAttribute["attribute_id"]; ?>
634
- <?php $attributeTitle = $_productAttribute["label"]; ?>
635
- if ( document.getElementById("attribute<?php echo $attributeId; ?>") !== null ) {
636
- _ra_optElfunc[<?php echo $attributeId; ?>] = document.getElementById("attribute<?php echo $attributeId; ?>").onchange;
637
- document.getElementById("attribute<?php echo $attributeId; ?>").onchange = function() {
638
- if ( _ra_optElfunc[<?php echo $attributeId; ?>] !== null ) _ra_optElfunc[<?php echo $attributeId; ?>]();
639
- _ra_triggerSetVariation();
640
- }
641
- }
642
- <?php endforeach ?>
643
- });
644
-
645
- <?php endif ?>
646
-
647
- <?php /*is configurable*/ ?>
648
- <?php endif ?>
649
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
650
 
651
- <?php endif ?>
652
- <?php endif ?>
653
- <?php endif //magento version ?>
 
 
 
 
 
 
 
 
 
 
654
 
 
655
 
656
- <?php
657
- /*
658
- ----------------------- Trigger addToWishlist -----------------------
659
- */
660
- ?>
661
- <?php if ( $info = Mage::getSingleton('core/session')->getTriggerAddToWishlist() ) : ?>
662
-
663
- // Trigger addToWishlist
664
-
665
- <?php $referral = Mage::getSingleton('core/session')->getReferralController(); echo "/*".$referral."*/"; ?>
666
- <?php if ( $referral != "product" ) : ?>
667
-
668
- // Trigger sendProduct before addToWishlist
669
-
670
- <?php
671
- $_product = Mage::getModel('catalog/product')->load($info['product_id']);
672
- $_productUrl = $_product->getProductUrl();
673
- $_category = false;
674
-
675
- $_productCategoryIds = $_product->getCategoryIds();
676
- if ( count($_productCategoryIds) ) {
677
- $firstCategoryId = $_productCategoryIds[0];
678
- $_category = Mage::getModel('catalog/category')->load($firstCategoryId);
679
- }
680
-
681
- $_categoryParent = "false";
682
- $_categoryBreadcrumb = "[]";
683
-
684
- if($_category) {
685
- if ( $_category->getLevel() > 2 ) {
686
- $_categoryParent = '"'.$_category->getParentId().'"';
687
- $_categoryBreadcrumb = array();
688
- $breadcrumbCategory = $_category;
689
- while ( $breadcrumbCategory->getLevel() > 2 ) {
690
- $breadcrumbCategory = Mage::getModel('catalog/category')->load($breadcrumbCategory->getParentId());
691
-
692
- $_categoryBreadcrumb[] = '{
693
- "id": "'.$breadcrumbCategory->getId().'",
694
- "name": "'.htmlspecialchars($breadcrumbCategory->getName()).'",
695
- "parent": '.( $breadcrumbCategory->getLevel() > 2 ? '"'.$breadcrumbCategory->getParentId().'"' : 'false' ).'
696
  }';
697
- }
698
- $_categoryBreadcrumb = '['.implode(', ', $_categoryBreadcrumb).']';
699
- }
700
- $_category = '[{
701
- "id": "'.$_category->getId().'",
702
- "name": "'.htmlspecialchars($_category->getName()).'",
703
- "parent": '.$_categoryParent.',
704
- "breadcrumb" : '.$_categoryBreadcrumb.
705
- '}]';
706
- } else {
707
- $_category = '[{"id": "-1", "name": "no category", "parent": false}]';
708
- }
709
- ?>
710
-
711
- var _ra = _ra || {};
712
- _ra.sendProductInfo = {
713
- "id": "<?php echo $_product->getId(); ?>",
714
- "name": "<?php echo htmlspecialchars($_product->getName()); ?>",
715
- "url": "<?php echo htmlspecialchars(strtok($_productUrl,'?')); ?>",
716
- "img": "<?php echo htmlspecialchars( Mage::helper('catalog/image')->init($_product, 'image')->resize(500) ); ?>",
717
- "price": <?php echo Mage::helper('tax')->getPrice($_product, $_product->getPrice()); ?>,
718
- "promo": <?php echo ( Mage::helper('tax')->getPrice($_product, $_product->getPrice()) - Mage::helper('tax')->getPrice($_product, $_product->getFinalPrice()) > 0 ? Mage::helper('tax')->getPrice($_product, $_product->getFinalPrice()) : 0 ); ?>,
719
- "inventory": {
720
- "variations": false,
721
- "stock": <?php echo $_product->getIsInStock() ?>
722
- },
723
- "brand": false,
724
- "category": <?php echo $_category; ?>,
725
- "callback_function": function() {
726
- _ra.addToWishlistInfo = {
727
- "product_id": "<?php echo $info['product_id']; ?>"
728
- };
729
- if(typeof _ra.addToWishlist !== "undefined") _ra.addToWishlist(_ra.addToWishlistInfo.product_id);
730
- }
731
- };
732
-
733
- if (_ra.ready !== undefined) {
734
- if(typeof _ra.sendProduct !== "undefined") _ra.sendProduct(_ra.sendProductInfo);
735
- }
736
-
737
- <?php else : ?>
738
-
739
- var _ra = _ra || {};
740
- _ra.addToWishlistInfo = {
741
- "product_id": "<?php echo $info['product_id']; ?>"
742
- };
743
-
744
- if (_ra.ready !== undefined) {
745
- if(typeof _ra.addToWishlist !== "undefined") _ra.addToWishlist(_ra.addToWishlistInfo.product_id);
746
- }
747
-
748
- <?php endif ?>
749
-
750
- <?php Mage::getSingleton('core/session')->unsTriggerAddToWishlist(); ?>
751
- <?php endif ?>
752
 
 
 
 
 
 
753
 
 
754
 
755
- <?php
756
- /*
757
- ----------------------- Trigger clickImage -----------------------
758
- */
759
- ?>
760
- <?php if ( Mage::app()->getFrontController()->getRequest()->getControllerName() == "product" && !is_null(Mage::registry('product')) ) : ?>
761
 
762
- // Trigger clickImage
 
 
 
 
763
 
 
 
 
 
764
  <?php
765
- $_product = Mage::registry('current_product');
766
- if($_product) :
 
 
767
  ?>
768
- <?php
769
 
770
- $customClass = Mage::helper('retargeting_tracker')->getCustomClass();
771
- if(Mage::helper('retargeting_tracker')->getCustomClass() != "") :
772
- ?>
773
 
774
- function _ra_triggerClickImage() {
775
- if(typeof _ra.clickImage !== "undefined") _ra.clickImage("<?php echo $_product->getId(); ?>");
776
- }
777
- _ra_helper_addLoadEvent(function() {
778
- if ( document.getElementsByClassName("<?php echo $customClass ?>").length > 0 ) {
779
- document.getElementsByClassName("<?php echo $customClass ?>")[0].onmouseover = _ra_triggerClickImage;
780
 
 
 
 
 
 
781
  }
782
- });
783
- //custom css
784
- <?php else : ?>
785
- function _ra_triggerClickImage() {
786
- if(typeof _ra.clickImage !== "undefined") _ra.clickImage("<?php echo $_product->getId(); ?>");
 
 
 
 
 
 
 
 
 
787
  }
 
788
 
789
- _ra_helper_addLoadEvent(function() {
790
- if ( document.getElementsByClassName("zoomWindow").length > 0 ) {
791
- document.getElementsByClassName("zoomWindow")[0].onmouseover = _ra_triggerClickImage;
 
 
 
 
 
 
 
 
 
 
 
792
  }
793
- if ( document.getElementsByClassName("zoomLens").length > 0 ) {
794
- document.getElementsByClassName("zoomLens")[0].onmouseover = _ra_triggerClickImage;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
795
  }
796
- if ( document.getElementsByClassName("MagicToolboxContainer").length > 0 ) {
797
- document.getElementsByClassName("MagicZoomBigImageCont")[0].onmouseover = _ra_triggerClickImage;
 
 
 
 
 
 
 
 
 
 
798
  }
799
- if ( document.getElementById("image") !== null ) {
800
- document.getElementById("image").onclick = _ra_triggerClickImage;
801
- } else if ( document.querySelector(".product-image img") !== null ) {
802
- var el = document.querySelector(".product-image img").onclick = _ra_triggerClickImage;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
803
  }
804
- });
805
- <?php endif //customcss?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
806
  <?php endif //endif product ?>
807
- <?php endif ?>
808
 
809
 
810
 
811
- <?php
812
- /*
813
- ----------------------- Trigger commentOnProduct -----------------------
814
- */
815
- ?>
816
- <?php if ( $info = Mage::getSingleton('core/session')->getTriggerCommentOnProduct() ) : ?>
817
-
818
- // Trigger commentOnProduct
819
-
820
- var _ra = _ra || {};
821
- _ra.commentOnProductInfo = {
822
- "product_id" : "<?php echo $info['product_id']; ?>"
823
- };
824
-
825
- if (_ra.ready !== undefined) {
826
- if(typeof _ra.commentOnProduct !== "undefined") _ra.commentOnProduct(_ra.commentOnProductInfo.product_id);
827
- }
828
-
829
- <?php Mage::getSingleton('core/session')->unsTriggerCommentOnProduct(); ?>
830
- <?php endif ?>
831
 
 
832
 
 
 
 
 
833
 
834
- <?php
835
- /*
836
- ----------------------- Trigger mouseOverPrice -----------------------
837
- */
838
- ?>
839
- <?php if ( Mage::app()->getFrontController()->getRequest()->getControllerName() == "product" && !is_null(Mage::registry('product')) ) : ?>
840
-
841
- // Trigger mouseOverPrice
842
-
843
- <?php $_product = Mage::registry('current_product'); ?>
844
- <?php if($_product): ?>
845
- function _ra_triggerMouseOverPrice() {
846
- if(typeof _ra.mouseOverPrice !== "undefined") _ra.mouseOverPrice("<?php echo $_product->getId(); ?>", {
847
- "price": <?php echo Mage::helper('tax')->getPrice($_product, $_product->getPrice()); ?>,
848
- "promo": <?php echo ( Mage::helper('tax')->getPrice($_product, $_product->getPrice()) - Mage::helper('tax')->getPrice($_product, $_product->getFinalPrice()) > 0 ? Mage::helper('tax')->getPrice($_product, $_product->getFinalPrice()) : 0 ); ?>
849
- });
850
- }
851
-
852
- _ra_helper_addLoadEvent(function() {
853
- if ( document.getElementById("product-price-<?php echo $_product->getId(); ?>") !== null ) {
854
- document.getElementById("product-price-<?php echo $_product->getId(); ?>").onmouseover = _ra_triggerMouseOverPrice;
855
- }
856
- if ( document.getElementById("old-price-<?php echo $_product->getId(); ?>") !== null ) {
857
- document.getElementById("old-price-<?php echo $_product->getId(); ?>").onmouseover = _ra_triggerMouseOverPrice;
858
- }
859
- });
860
 
861
- <?php endif ?>
862
- <?php endif ?>
863
 
864
 
865
 
866
- <?php
867
- /*
868
- ----------------------- Trigger mouseOverAddToCart -----------------------
869
- */
870
- ?>
871
- <?php if ( Mage::app()->getFrontController()->getRequest()->getControllerName() == "product" && !is_null(Mage::registry('product')) ) : ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
872
 
873
- // Trigger mouseOverAddToCart
 
 
 
 
 
 
 
874
 
875
- <?php $_product = Mage::registry('current_product'); ?>
876
- <?php if($_product): ?>
877
- function _ra_triggerMouseOverAddToCart() {
878
- if(typeof _ra.mouseOverAddToCart !== "undefined") _ra.mouseOverAddToCart("<?php echo $_product->getId(); ?>");
879
- }
880
 
881
- _ra_helper_addLoadEvent(function() {
882
- if ( document.getElementById("product-addtocart-button") !== null ) {
883
- document.getElementById("product-addtocart-button").onmouseover = _ra_triggerMouseOverAddToCart;
884
- } else if ( document.getElementsByClassName("btn-cart").length > 0 ) {
885
- document.getElementsByClassName("btn-cart")[0].onmouseover = _ra_triggerMouseOverAddToCart;
886
- }
887
- });
888
 
889
- <?php endif ?>
890
- <?php endif ?>
891
 
 
 
 
 
 
 
892
 
 
893
 
894
- <?php
895
- /*
896
- ----------------------- Trigger saveOrder -----------------------
897
- */
898
- ?>
899
- <?php if ( $info = Mage::getSingleton('core/session')->getTriggerSaveOrder() ) : ?>
900
-
901
- // Trigger saveOrder
902
-
903
- var _ra = _ra || {};
904
- _ra.saveOrderInfo = {
905
- "order_no": "<?php echo $info['order_no']; ?>",
906
- "lastname": "<?php echo htmlspecialchars($info['lastname']); ?>",
907
- "firstname": "<?php echo htmlspecialchars($info['firstname']); ?>",
908
- "email": "<?php echo htmlspecialchars($info['email']); ?>",
909
- "phone": "<?php echo htmlspecialchars($info['phone']); ?>",
910
- "state": "<?php echo htmlspecialchars($info['state']); ?>",
911
- "city": "<?php echo htmlspecialchars($info['city']); ?>",
912
- "address": "<?php echo htmlspecialchars($info['address']); ?>",
913
- "discount": <?php echo $info['discount']; ?>,
914
- "discount_code": "<?php echo $info['discount_code']; ?>",
915
- "shipping": <?php echo $info['shipping']; ?>,
916
- "total": <?php echo $info['total']; ?>,
917
- };
918
- _ra.saveOrderProducts = <?php echo $info['products']; ?>
919
-
920
- if( _ra.ready !== undefined ){
921
- if(typeof _ra.saveOrder !== "undefined") _ra.saveOrder(_ra.saveOrderInfo, _ra.saveOrderProducts);
922
- }
923
-
924
- <?php Mage::getSingleton('core/session')->unsTriggerSaveOrder(); ?>
925
- <?php endif ?>
926
 
 
 
 
 
 
 
 
927
 
 
 
928
 
929
- <?php
930
- /*
931
- ----------------------- Trigger visitHelpPage -----------------------
932
- */
933
- ?>
934
- <?php if ( Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms' ) : ?>
935
-
936
- <?php
937
- $page = Mage::getSingleton('cms/page');
938
- $helpPages = Mage::getStoreConfig('retargetingtracker_options/more/help_pages');
939
- $helpPages = explode(',', $helpPages);
940
- ?>
941
-
942
- <?php if ( $page->getId() && in_array($page->getId(), $helpPages) ) : ?>
943
-
944
- // Trigger visitHelpPage
945
-
946
- var _ra = _ra || {};
947
- _ra.visitHelpPageInfo = {
948
- "visit" : true
949
- }
950
-
951
- if (_ra.ready !== undefined) {
952
- if(typeof _ra.visitHelpPage !== "undefined") _ra.visitHelpPage();
953
- }
954
-
955
- <?php endif ?>
956
 
957
 
958
- <?php endif ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
959
 
 
 
 
 
 
960
 
 
 
961
 
962
- <?php
963
- /*
964
- ----------------------- Trigger checkoutIds -----------------------
965
- */
966
- ?>
967
- <?php
968
- $request = $this->getRequest();
969
- $module = $request->getModuleName();
970
- $controller = $request->getControllerName();
971
- $action = $request->getActionName();
972
- ?>
973
- <?php
974
- if ( ($module == 'checkout' && $controller == 'cart' && $action == 'index') ||
975
- ($module == 'checkout' && $controller == 'onepage' && $action == 'index') ||
976
- (Mage::getURL('checkout/onepage') == Mage::helper('core/url')->getCurrentUrl()) ||
977
- (strrpos(Mage::helper('core/url')->getCurrentUrl(), "/onestepcheckout") !== false)
978
- ) : ?>
979
-
980
- // Trigger checkoutIds
981
-
982
- <?php
983
- $items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
984
- $products = array();
985
- foreach($items as $item) {
986
- $products[] = $item->getProductId();
987
- }
988
- $products = implode(", ", $products);
989
- ?>
990
-
991
- var _ra = _ra || {};
992
- _ra.checkoutIdsInfo = [<?php echo $products; ?>];
993
-
994
- if (_ra.ready !== undefined) {
995
- if(typeof _ra.checkoutIds !== "undefined") _ra.checkoutIds(_ra.checkoutIdsInfo);
996
- }
997
 
998
- <?php endif ?>
999
 
 
 
 
 
 
 
1000
 
1001
- <?php // likeFacebook
1002
- $_product = Mage::registry('current_product');
1003
- if($_product && Mage::helper('retargeting_tracker')->isFacebookAvailable()) :
1004
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1005
 
1006
- if (typeof FB != "undefined") {
1007
- FB.Event.subscribe('edge.create', function () {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1008
  _ra.likeFacebook(<?php echo $_product->getId()?>);
1009
  });
1010
- };
1011
- <?php endif; //end like facebook ?>
1012
 
1013
  </script>
1014
  <?php
@@ -1017,5 +1058,5 @@ if (typeof FB != "undefined") {
1017
  */
1018
  ?>
1019
  <?php
1020
- Mage::getSingleton('core/session')->setReferralController( Mage::app()->getFrontController()->getRequest()->getControllerName() );
1021
  ?>
7
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
  */
9
  ?>
10
+ <?php
11
  /**
12
+ * Retargeting Triggers code
13
+ **/
14
  ?>
15
  <?php $magentoVersion = Mage::getVersion(); ?>
16
 
17
+ <?php if (Mage::app()->getFrontController()->getRequest()->getControllerName() == "product" && !is_null(Mage::registry('product'))) : ?>
18
+ <script>
19
+ // Retargeting JS helpers
20
+ function _ra_helper_addLoadEvent(func) {
21
+ var oldonload = window.onload;
22
+ if (typeof window.onload != 'function') {
23
+ window.onload = func;
24
+ } else {
25
+ window.onload = function () {
26
+ if (oldonload) {
27
+ oldonload();
28
+ }
29
+ func();
30
+ };
31
+ }
32
+ }
33
+ </script>
34
  <?php endif ?>
35
 
36
  <script>
37
+ <?php
38
+ /*
39
+ ----------------------- Trigger setEmail -----------------------
40
+ */
41
+ ?>
42
+ <?php if ( $info = Mage::getSingleton('core/session')->getTriggerSetEmail() ) : ?>
43
+ // Trigger setEmail
44
+ var _ra = _ra || {};
45
+ _ra.setEmailInfo = {
46
+ "email": "<?php echo htmlspecialchars($info['email']); ?>",
47
+ "name": "<?php echo htmlspecialchars($info['name']); ?>",
48
+ "phone": "<?php echo htmlspecialchars($info['phone']); ?>",
49
+ "city": "<?php echo htmlspecialchars($info['city']); ?>",
50
+ "sex": "<?php echo htmlspecialchars($info['sex']); ?>"
51
+ };
52
+ if (_ra.ready !== undefined) {
53
+ if (typeof _ra.setEmail !== "undefined") {
54
+ _ra.setEmail(_ra.setEmailInfo);
55
+ }
56
+ }
57
+ <?php Mage::getSingleton('core/session')->unsTriggerSetEmail(); ?>
58
+ <?php endif ?>
59
+ <?php
60
+ /*
61
+ ----------------------- Trigger sendCategory -----------------------
62
+ */
63
+ ?>
64
+ <?php if ( Mage::app()->getFrontController()->getRequest()->getControllerName() == "category" ) : ?>
65
+
66
+ // Trigger sendCategory
67
+
68
+ <?php $_category = Mage::registry('current_category'); ?>
69
+ <?php
70
+ $_categoryParent = "false";
71
+ $_categoryBreadcrumb = "[]";
72
+ if ($_category->getLevel() > 2) {
73
+ $_categoryParent = '"' . $_category->getParentId() . '"';
74
+ $_categoryBreadcrumb = array();
75
+ $breadcrumbCategory = $_category;
76
+ while ($breadcrumbCategory->getLevel() > 2) {
77
+ $breadcrumbCategory = Mage::getModel('catalog/category')->load($breadcrumbCategory->getParentId());
78
+
79
+ $_categoryBreadcrumb[] = '[{
80
+ "id": "' . $breadcrumbCategory->getId() . '",
81
+ "name": "' . htmlspecialchars($breadcrumbCategory->getName()) . '",
82
+ "parent": ' . ($breadcrumbCategory->getLevel() > 2 ? '"' . $breadcrumbCategory->getParentId() . '"' : 'false') . '
83
  }]';
84
+ }
85
+ $_categoryBreadcrumb = '[' . implode(', ', $_categoryBreadcrumb) . ']';
86
+ }
87
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
88
 
89
+ var _ra = _ra || {};
90
+ _ra.sendCategoryInfo = {
91
+ "id": "<?php echo $_category->getId(); ?>",
92
+ "name": "<?php echo htmlspecialchars($_category->getName()); ?>",
93
+ "parent": <?php echo $_categoryParent; ?>,
94
+ "breadcrumb": <?php echo $_categoryBreadcrumb; ?>
95
+ };
96
+
97
+ if (_ra.ready !== undefined) {
98
+ if (typeof _ra.sendCategory !== "undefined") {
99
+ _ra.sendCategory(_ra.sendCategoryInfo);
100
+ }
101
+ }
102
+
103
+ <?php endif ?>
104
+ <?php
105
+ /*
106
+ ----------------------- Trigger sendBrand -----------------------
107
+ magento doesn't have core support for brands..
108
+ */
109
+ ?>
110
+ <?php
111
+ /*
112
+ ----------------------- Trigger sendProduct -----------------------
113
+ */
114
+ ?>
115
+ <?php if ( Mage::app()->getFrontController()->getRequest()->getControllerName() == "product" && !is_null(Mage::registry('product')) ) : ?>
116
+
117
+ // Trigger sendProduct
118
+
119
+ <?php $_product = Mage::registry('current_product'); ?>
120
+
121
+ <?php if($_product) : ?>
122
+ <?php
123
+ $_productUrl = Mage::helper('core/url')->getCurrentUrl();
124
+
125
+ $_category = false;
126
+ if (Mage::registry('current_category')) {
127
+ $_category = Mage::registry('current_category');
128
+ } else {
129
+ $_productCategoryIds = $_product->getCategoryIds();
130
+ if (count($_productCategoryIds)) {
131
+ $firstCategoryId = $_productCategoryIds[0];
132
+ $_category = Mage::getModel('catalog/category')->load($firstCategoryId);
133
+ }
134
+ }
135
+
136
+ $_categoryParent = "false";
137
+ $_categoryBreadcrumb = "[]";
138
+
139
+ if ($_category) {
140
+ if ($_category->getLevel() > 2) {
141
+ $_categoryParent = '"' . $_category->getParentId() . '"';
142
+ $_categoryBreadcrumb = array();
143
+ $breadcrumbCategory = $_category;
144
+ while ($breadcrumbCategory->getLevel() > 2) {
145
+ $breadcrumbCategory = Mage::getModel('catalog/category')->load($breadcrumbCategory->getParentId());
146
+ $_categoryBreadcrumb[] = '{
147
+ "id": "' . $breadcrumbCategory->getId() . '",
148
+ "name": "' . htmlspecialchars($breadcrumbCategory->getName()) . '",
149
+ "parent": ' . ($breadcrumbCategory->getLevel() > 2 ? '"' . $breadcrumbCategory->getParentId() . '"' : 'false') . '
150
  }';
151
+ }
152
+ $_categoryBreadcrumb = '[' . implode(', ', $_categoryBreadcrumb) . ']';
153
+ }
154
+ $_category = '[{
155
+ "id": "' . $_category->getId() . '",
156
+ "name": "' . htmlspecialchars($_category->getName()) . '",
157
+ "parent": ' . $_categoryParent . ',
158
+ "breadcrumb" : ' . $_categoryBreadcrumb . '}]';
159
+ } else {
160
+ $_category = '[{
 
161
  "id": "-1",
162
  "name": "no category",
163
  "parent": false
164
  }]';
165
+ }
166
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
 
168
+ var _ra = _ra || {};
169
+ _ra.sendProductInfo = {
170
+ "id": "<?php echo $_product->getId(); ?>",
171
+ "name": "<?php echo htmlspecialchars($_product->getName()); ?>",
172
+ "url": "<?php echo htmlspecialchars(strtok($_productUrl, '?')); ?>",
173
+ "img": "<?php echo htmlspecialchars(Mage::helper('catalog/image')->init($_product, 'image')->resize(500)); ?>",
174
+ "price": <?php echo Mage::helper('tax')->getPrice($_product, $_product->getPrice()); ?>,
175
+ "promo": <?php echo(Mage::helper('tax')->getPrice($_product, $_product->getPrice()) - Mage::helper('tax')->getPrice($_product, $_product->getFinalPrice()) > 0 ? Mage::helper('tax')->getPrice($_product, $_product->getFinalPrice()) : 0); ?>,
176
+ "inventory": {
177
+ "variations": false,
178
+ "stock": <?php echo $_product->getIsInStock() ?>
179
+ },
180
+ "brand": false,
181
+ "category": <?php echo $_category; ?>
182
+ };
183
 
184
+ if (_ra.ready !== undefined) {
185
+ if (typeof _ra.sendProduct !== "undefined") {
186
+ _ra.sendProduct(_ra.sendProductInfo);
187
+ }
188
+ }
189
+ <?php endif ?>
190
+ <?php endif ?>
191
+ <?php
192
+ /*
193
+ ----------------------- Trigger addToCart -----------------------
194
+ */
195
+ ?>
196
+ <?php if ( $info = Mage::getSingleton('core/session')->getTriggerAddToCart() ) : ?>
197
 
198
+ // Trigger addToCart
199
 
200
+ <?php $referral = Mage::getSingleton('core/session')->getReferralController(); echo "/*" . $referral . "*/"; ?>
201
+ <?php if ( $referral != "product" ) : ?>
202
+
203
+ // Trigger sendProduct before addToCart
204
+
205
+ <?php
206
+ $_product = Mage::getModel('catalog/product')->load($info['product_id']);
207
+ $_productUrl = $_product->getProductUrl();
208
+ $_category = false;
209
+
210
+ $_productCategoryIds = $_product->getCategoryIds();
211
+ if (count($_productCategoryIds)) {
212
+ $firstCategoryId = $_productCategoryIds[0];
213
+ $_category = Mage::getModel('catalog/category')->load($firstCategoryId);
214
+ }
215
+
216
+ $_categoryParent = "false";
217
+ $_categoryBreadcrumb = "[]";
218
+
219
+ if ($_category) {
220
+ if ($_category->getLevel() > 2) {
221
+ $_categoryParent = '"' . $_category->getParentId() . '"';
222
+ $_categoryBreadcrumb = array();
223
+ $breadcrumbCategory = $_category;
224
+ while ($breadcrumbCategory->getLevel() > 2) {
225
+ $breadcrumbCategory = Mage::getModel('catalog/category')->load($breadcrumbCategory->getParentId());
226
+
227
+ $_categoryBreadcrumb[] = '{
228
+ "id": "' . $breadcrumbCategory->getId() . '",
229
+ "name": "' . htmlspecialchars($breadcrumbCategory->getName()) . '",
230
+ "parent": ' . ($breadcrumbCategory->getLevel() > 2 ? '"' . $breadcrumbCategory->getParentId() . '"' : 'false') . '
 
 
 
 
 
 
 
 
 
231
  }';
232
+ }
233
+ $_categoryBreadcrumb = '[' . implode(', ', $_categoryBreadcrumb) . ']';
234
+ }
235
+ $_category = '[{
236
+ "id": "' . $_category->getId() . '",
237
+ "name": "' . htmlspecialchars($_category->getName()) . '",
238
+ "parent": ' . $_categoryParent . ',
239
+ "breadcrumb" : ' . $_categoryBreadcrumb . '}]';
240
+ } else {
241
+ $_category = '[{"id": "-1", "name": "no category", "parent": false}]';
242
+ }
243
+ ?>
244
+
245
+ var _ra = _ra || {};
246
+ _ra.sendProductInfo = {
247
+ "id": "<?php echo $_product->getId(); ?>",
248
+ "name": "<?php echo htmlspecialchars($_product->getName()); ?>",
249
+ "url": "<?php echo htmlspecialchars(strtok($_productUrl, '?')); ?>",
250
+ "img": "<?php echo htmlspecialchars(Mage::helper('catalog/image')->init($_product, 'image')->resize(500)); ?>",
251
+ "price": <?php echo Mage::helper('tax')->getPrice($_product, $_product->getPrice()); ?>,
252
+ "promo": <?php echo(Mage::helper('tax')->getPrice($_product, $_product->getPrice()) - Mage::helper('tax')->getPrice($_product, $_product->getFinalPrice()) > 0 ? Mage::helper('tax')->getPrice($_product, $_product->getFinalPrice()) : 0); ?>,
253
+ "inventory": {
254
+ "variations": false,
255
+ "stock": <?php echo $_product->getIsInStock() ?>
256
+ },
257
+ "brand": false,
258
+ "category": <?php echo $_category; ?>,
259
+ "callback_function": function () {
260
+ _ra.addToCartInfo = {
261
+ "product_id": "<?php echo $info['product_id']; ?>",
262
+ "quantity": <?php echo $_product->getIsInStock() ?>,
263
+ "variation": <?php echo $info['variation']; ?>
264
+ };
265
+ if (typeof _ra.addToCart !== "undefined") {
266
+ _ra.addToCart(_ra.addToCartInfo.product_id, _ra.addToCartInfo.quantity, _ra.addToCartInfo.variation);
267
+ }
268
+ }
269
+ };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270
 
271
+ if (_ra.ready !== undefined) {
272
+ if (typeof _ra.sendProduct !== "undefined") {
273
+ _ra.sendProduct(_ra.sendProductInfo);
274
+ }
275
+ }
276
 
277
+ <?php else : ?>
278
 
279
+ var _ra = _ra || {};
280
+ _ra.addToCartInfo = {
281
+ "product_id": "<?php echo $info['product_id']; ?>",
282
+ "quantity": 1,
283
+ "variation": <?php echo $info['variation']; ?>
284
+ };
285
 
286
+ if (_ra.ready !== undefined) {
287
+ if (typeof _ra.addToCart !== "undefined") {
288
+ _ra.addToCart(_ra.addToCartInfo.product_id, _ra.addToCartInfo.quantity, _ra.addToCartInfo.variation);
289
+ }
290
+ }
291
 
292
+ <?php endif ?>
293
+
294
+ <?php Mage::getSingleton('core/session')->unsTriggerAddToCart(); ?>
295
+ <?php endif ?>
296
  <?php
297
+ /*
298
+ ----------------------- Trigger setVariation -----------------------
299
+ */
300
+ if($magentoVersion > "1.4.2.0") :
301
  ?>
302
+ <?php if ( Mage::app()->getFrontController()->getRequest()->getControllerName() == "product" && !is_null(Mage::registry('product')) ) : ?>
303
 
304
+ // Trigger setVariation
 
 
305
 
306
+ <?php $_product = Mage::registry('current_product'); ?>
307
+ <?php if ($_product) : ?>
308
+
309
+ <?php if ( !$_product->isConfigurable() ) : ?>
310
+ <?php /*is not configurable*/ ?>
311
+ <?php if ( $_product->getTypeInstance(true)->hasOptions($_product) ) : ?>
312
 
313
+ function _ra_triggerSetVariation() {
314
+ var _ra_variation = _ra_grabVariation();
315
+ if (typeof _ra.setVariation !== "undefined") {
316
+ _ra.setVariation("<?php echo $_product->getId(); ?>", _ra_variation);
317
+ }
318
  }
319
+
320
+ _ra_optElfunc = [];
321
+ function _ra_grabVariation() {
322
+ var _ra_vo = {};
323
+ var _ra_voCode = [];
324
+ var _ra_voDetails = {};
325
+ <?php foreach ( $_product->getOptions() as $o ) : ?>
326
+ <?php $optionType = $o->getType(); ?>
327
+ <?php $optionId = $o->getId(); ?>
328
+ <?php $optionTitle = $o->getTitle(); ?>
329
+
330
+ <?php if ( $optionType == "area" ) : ?>
331
+ if (document.querySelector(".product-custom-option[name='options[<?php echo $optionId; ?>]']") !== null) {
332
+ _ra_voCode.push(document.querySelector(".product-custom-option[name='options[<?php echo $optionId; ?>]']").value);
333
  }
334
+ <?php endif ?>
335
 
336
+ <?php if ( $optionType == "field" ) : ?>
337
+ if (document.querySelector(".product-custom-option[name='options[<?php echo $optionId; ?>]']") !== null) {
338
+ _ra_voCode.push(document.querySelector(".product-custom-option[name='options[<?php echo $optionId; ?>]']").value);
339
+ }
340
+ <?php endif ?>
341
+
342
+ <?php if ( $optionType == "checkbox" ) : ?>
343
+ if (document.querySelectorAll("input[type='checkbox'].product-custom-option[name='options[<?php echo $optionId; ?>][]']").length > 0) {
344
+ var _ra_optionValue = [];
345
+ var _ra_arr = document.querySelectorAll("input[type='checkbox'].product-custom-option[name='options[<?php echo $optionId; ?>][]']");
346
+ for (var index = 0; index < _ra_arr.length; index++) {
347
+ if (_ra_arr[index].checked) {
348
+ _ra_optionValue.push(document.querySelector("label[for='" + _ra_arr[index].getAttribute('id') + "']").innerText);
349
+ }
350
  }
351
+ _ra_voCode.push(_ra_optionValue.join(', '));
352
+ }
353
+ <?php endif ?>
354
+
355
+ <?php if ( $optionType == "date" ) : ?>
356
+ if (document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']") !== null) {
357
+ var _ra_optionValue = [];
358
+ _ra_optionValue.push(document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']").options[document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']").selectedIndex].text);
359
+ _ra_optionValue.push(document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']").options[document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']").selectedIndex].text);
360
+ _ra_optionValue.push(document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']").options[document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']").selectedIndex].text);
361
+ _ra_voCode.push(_ra_optionValue.join('/'));
362
+ }
363
+ <?php endif ?>
364
+
365
+ <?php if ( $optionType == "date_time" ) : ?>
366
+ if (document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']") !== null) {
367
+ var _ra_optionValue = [];
368
+ _ra_optionValue.push(document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']").options[document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']").selectedIndex].text);
369
+ _ra_optionValue.push(document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']").options[document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']").selectedIndex].text);
370
+ _ra_optionValue.push(document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']").options[document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']").selectedIndex].text);
371
+ _ra_optionValue.push(document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']").options[document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']").selectedIndex].text);
372
+ _ra_optionValue.push(document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']").options[document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']").selectedIndex].text);
373
+ _ra_optionValue.push(document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']").options[document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']").selectedIndex].text);
374
+ _ra_voCode.push(_ra_optionValue.join('/'));
375
+ }
376
+ <?php endif ?>
377
+
378
+ <?php if ( $optionType == "drop_down" ) : ?>
379
+ if (document.querySelector("select.product-custom-option[name='options[<?php echo $optionId; ?>]']").value !== null) {
380
+ _ra_voCode.push(document.querySelector("select.product-custom-option[name='options[<?php echo $optionId; ?>]']").options[document.querySelector("select.product-custom-option[name='options[<?php echo $optionId; ?>]']").selectedIndex].text);
381
+ }
382
+ <?php endif ?>
383
+ <?php if ( $optionType == "multiple" ) : ?>
384
+ if (document.querySelector("select.multiselect.product-custom-option[name='options[<?php echo $optionId; ?>][]']") !== null) {
385
+ var _ra_optionValue = [];
386
+ var _ra_arr = document.querySelector("select.multiselect.product-custom-option[name='options[<?php echo $optionId; ?>][]']").options;
387
+ for (var index = 0; index < _ra_arr.length; index++) {
388
+ if (_ra_arr[index].selected) {
389
+ _ra_optionValue.push(_ra_arr[index].text);
390
+ }
391
  }
392
+ _ra_voCode.push(_ra_optionValue.join('_'));
393
+ }
394
+ <?php endif ?>
395
+
396
+ <?php if ( $optionType == "radio" ) : ?>
397
+ if (document.querySelectorAll("input[type='radio'].product-custom-option[name='options[<?php echo $optionId; ?>]']").length > 0) {
398
+ var _ra_optionValue = [];
399
+ var _ra_arr = document.querySelectorAll("input[type='radio'].product-custom-option[name='options[<?php echo $optionId; ?>]']");
400
+ for (var index = 0; index < _ra_arr.length; index++) {
401
+ if (_ra_arr[index].checked) {
402
+ _ra_optionValue.push(document.querySelector("label[for='" + _ra_arr[index].getAttribute('id') + "']").innerText);
403
+ }
404
  }
405
+ _ra_voCode.push(_ra_optionValue.join(', '));
406
+ }
407
+ <?php endif ?>
408
+ <?php if ( $optionType == "time" ) : ?>
409
+ if (document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']") !== null) {
410
+ var _ra_optionValue = [];
411
+ _ra_optionValue.push(document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']").options[document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']").selectedIndex].text);
412
+ _ra_optionValue.push(document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']").options[document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']").selectedIndex].text);
413
+ _ra_optionValue.push(document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']").options[document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']").selectedIndex].text);
414
+ _ra_voCode.push(_ra_optionValue.join('/'));
415
+ }
416
+ <?php endif ?>
417
+
418
+ <?php if ( $optionType == "file" ) : ?>
419
+ if (document.querySelector("input[type='file'].product-custom-option[name='options_<?php echo $optionId; ?>_file']") !== null) {
420
+ _ra_voCode.push(document.querySelector("input[type='file'].product-custom-option[name='options_<?php echo $optionId; ?>_file']").value.split(/(\\|\/)/g).pop());
421
+ }
422
+ <?php endif ?>
423
+
424
+ _ra_voDetails[_ra_voCode[_ra_voCode.length - 1].replace(RegExp("[- ]", 'g'), '')] = {
425
+ "category_name": "<?php echo $optionTitle; ?>",
426
+ "category": "<?php echo $optionTitle; ?>",
427
+ "value": _ra_voCode[_ra_voCode.length - 1]
428
+ };
429
+ _ra_voCode[_ra_voCode.length - 1] = _ra_voCode[_ra_voCode.length - 1].replace(RegExp("[- ]", 'g'), '');
430
+
431
+ <?php endforeach ?>
432
+
433
+ var _ra_vo = {
434
+ "code": _ra_voCode.join('-'),
435
+ "stock": 1,
436
+ "details": _ra_voDetails
437
+ };
438
+ return _ra_vo;
439
+ }
440
+ _ra_helper_addLoadEvent(function () {
441
+ <?php foreach ( $_product->getOptions() as $o ) : ?>
442
+ <?php $optionType = $o->getType(); ?>
443
+ <?php $optionId = $o->getId(); ?>
444
+
445
+ <?php if ( $optionType == "area" ) : ?>
446
+ if (document.querySelector(".product-custom-option[name='options[<?php echo $optionId; ?>]']") !== null) {
447
+ _ra_optElfunc[<?php echo $optionId; ?>] = document.querySelector(".product-custom-option[name='options[<?php echo $optionId; ?>]']").onchange;
448
+ document.querySelector(".product-custom-option[name='options[<?php echo $optionId; ?>]']").onchange = function () {
449
+ if (_ra_optElfunc[<?php echo $optionId; ?>] !== null) _ra_optElfunc[<?php echo $optionId; ?>]();
450
+ _ra_triggerSetVariation();
451
+ };
452
+ }
453
+ <?php endif ?>
454
+
455
+ <?php if ( $optionType == "field" ) : ?>
456
+ if (document.querySelector(".product-custom-option[name='options[<?php echo $optionId; ?>]']") !== null) {
457
+ _ra_optElfunc[<?php echo $optionId; ?>] = document.querySelector(".product-custom-option[name='options[<?php echo $optionId; ?>]']").onchange;
458
+ document.querySelector(".product-custom-option[name='options[<?php echo $optionId; ?>]']").onchange = function () {
459
+ if (_ra_optElfunc[<?php echo $optionId; ?>] !== null) _ra_optElfunc[<?php echo $optionId; ?>]();
460
+ _ra_triggerSetVariation();
461
+ };
462
+ }
463
+ <?php endif ?>
464
+
465
+ <?php if ( $optionType == "checkbox" ) : ?>
466
+ if (document.querySelectorAll("input[type='checkbox'].product-custom-option[name='options[<?php echo $optionId; ?>][]']").length > 0) {
467
+ _ra_optElfunc[<?php echo $optionId; ?>] = [];
468
+ for (var index = 0; index < document.querySelectorAll("input[type='checkbox'].product-custom-option[name='options[<?php echo $optionId; ?>][]']").length; index++) {
469
+ _ra_optElfunc[document.querySelectorAll("input[type='checkbox'].product-custom-option[name='options[<?php echo $optionId; ?>][]']")[index]] = document.querySelectorAll("input[type='checkbox'].product-custom-option[name='options[<?php echo $optionId; ?>][]']")[index].onclick;
470
+ document.querySelectorAll("input[type='checkbox'].product-custom-option[name='options[<?php echo $optionId; ?>][]']")[index].onclick = function () {
471
+ if (_ra_optElfunc[this] !== null) {
472
+ _ra_optElfunc[this]();
473
+ _ra_triggerSetVariation();
474
+ }
475
+ };
476
  }
477
+ }
478
+ <?php endif ?>
479
+
480
+ <?php if ( $optionType == "date" ) : ?>
481
+ if (document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']") !== null) {
482
+ _ra_optElfunc[<?php echo $optionId; ?>] = [];
483
+ _ra_optElfunc[<?php echo $optionId; ?>][0] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']").onchange;
484
+ _ra_optElfunc[<?php echo $optionId; ?>][1] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']").onchange;
485
+ _ra_optElfunc[<?php echo $optionId; ?>][2] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']").onchange;
486
+ document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']").onchange = function () {
487
+ if (_ra_optElfunc[<?php echo $optionId; ?>][0] !== null) _ra_optElfunc[<?php echo $optionId; ?>][0]();
488
+ _ra_triggerSetVariation();
489
+ };
490
+ document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']").onchange = function () {
491
+ if (_ra_optElfunc[<?php echo $optionId; ?>][1] !== null) _ra_optElfunc[<?php echo $optionId; ?>][1]();
492
+ _ra_triggerSetVariation();
493
+ };
494
+ document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']").onchange = function () {
495
+ if (_ra_optElfunc[<?php echo $optionId; ?>][2] !== null) _ra_optElfunc[<?php echo $optionId; ?>][2]();
496
+ _ra_triggerSetVariation();
497
+ };
498
+ }
499
+ <?php endif ?>
500
+
501
+ <?php if ( $optionType == "date_time" ) : ?>
502
+ if (document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']") !== null) {
503
+ _ra_optElfunc[<?php echo $optionId; ?>] = [];
504
+ _ra_optElfunc[<?php echo $optionId; ?>][0] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']").onchange;
505
+ _ra_optElfunc[<?php echo $optionId; ?>][1] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']").onchange;
506
+ _ra_optElfunc[<?php echo $optionId; ?>][2] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']").onchange;
507
+ _ra_optElfunc[<?php echo $optionId; ?>][3] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']").onchange;
508
+ _ra_optElfunc[<?php echo $optionId; ?>][4] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']").onchange;
509
+ _ra_optElfunc[<?php echo $optionId; ?>][5] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']").onchange;
510
+ document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']").onchange = function () {
511
+ if (_ra_optElfunc[<?php echo $optionId; ?>][0] !== null) _ra_optElfunc[<?php echo $optionId; ?>][0]();
512
+ _ra_triggerSetVariation();
513
+ };
514
+ document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']").onchange = function () {
515
+ if (_ra_optElfunc[<?php echo $optionId; ?>][1] !== null) _ra_optElfunc[<?php echo $optionId; ?>][1]();
516
+ _ra_triggerSetVariation();
517
+ };
518
+ document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']").onchange = function () {
519
+ if (_ra_optElfunc[<?php echo $optionId; ?>][2] !== null) _ra_optElfunc[<?php echo $optionId; ?>][2]();
520
+ _ra_triggerSetVariation();
521
+ };
522
+ document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']").onchange = function () {
523
+ if (_ra_optElfunc[<?php echo $optionId; ?>][3] !== null) _ra_optElfunc[<?php echo $optionId; ?>][3]();
524
+ _ra_triggerSetVariation();
525
+ };
526
+ document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']").onchange = function () {
527
+ if (_ra_optElfunc[<?php echo $optionId; ?>][4] !== null) _ra_optElfunc[<?php echo $optionId; ?>][4]();
528
+ _ra_triggerSetVariation();
529
+ };
530
+ document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']").onchange = function () {
531
+ if (_ra_optElfunc[<?php echo $optionId; ?>][5] !== null) _ra_optElfunc[<?php echo $optionId; ?>][5]();
532
+ _ra_triggerSetVariation();
533
+ }
534
+ }
535
+ <?php endif ?>
536
+
537
+ <?php if ( $optionType == "drop_down" ) : ?>
538
+ if (document.querySelector("select.product-custom-option[name='options[<?php echo $optionId; ?>]']") !== null) {
539
+ _ra_optElfunc[<?php echo $optionId; ?>] = document.querySelector("select.product-custom-option[name='options[<?php echo $optionId; ?>]']").onchange;
540
+ document.querySelector("select.product-custom-option[name='options[<?php echo $optionId; ?>]']").onchange = function () {
541
+ if (_ra_optElfunc[<?php echo $optionId; ?>] !== null) {
542
+ _ra_optElfunc[<?php echo $optionId; ?>]();
543
+ _ra_triggerSetVariation();
544
+ }
545
+ };
546
+ }
547
+ <?php endif ?>
548
+
549
+ <?php if ( $optionType == "multiple" ) : ?>
550
+ if (document.querySelector("select.multiselect.product-custom-option[name='options[<?php echo $optionId; ?>][]']") !== null) {
551
+ _ra_optElfunc[<?php echo $optionId; ?>] = document.querySelector("select.multiselect.product-custom-option[name='options[<?php echo $optionId; ?>][]']").onchange;
552
+ document.querySelector("select.multiselect.product-custom-option[name='options[<?php echo $optionId; ?>][]']").onchange = function () {
553
+ if (_ra_optElfunc[<?php echo $optionId; ?>] !== null) _ra_optElfunc[<?php echo $optionId; ?>]();
554
+ _ra_triggerSetVariation();
555
+ };
556
+ }
557
+ <?php endif ?>
558
+
559
+ <?php if ( $optionType == "radio" ) : ?>
560
+ if (document.querySelectorAll("input[type='radio'].product-custom-option[name='options[<?php echo $optionId; ?>]']").length > 0) {
561
+ _ra_optElfunc[<?php echo $optionId; ?>] = [];
562
+ for (var index = 0; index < document.querySelectorAll("input[type='radio'].product-custom-option[name='options[<?php echo $optionId; ?>]']").length; index++) {
563
+ _ra_optElfunc[document.querySelectorAll("input[type='radio'].product-custom-option[name='options[<?php echo $optionId; ?>]']")[index]] = document.querySelectorAll("input[type='radio'].product-custom-option[name='options[<?php echo $optionId; ?>]']")[index].onclick;
564
+ document.querySelectorAll("input[type='radio'].product-custom-option[name='options[<?php echo $optionId; ?>]']")[index].onclick = function () {
565
+ if (_ra_optElfunc[this] !== null) {
566
+ _ra_optElfunc[this]();
567
+ }
568
+ _ra_triggerSetVariation();
569
+ };
570
+ }
571
+ }
572
+ <?php endif ?>
573
+
574
+ <?php if ( $optionType == "time" ) : ?>
575
+ if (document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']") !== null && document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']") !== null) {
576
+ _ra_optElfunc[<?php echo $optionId; ?>] = [];
577
+ _ra_optElfunc[<?php echo $optionId; ?>][0] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']").onchange;
578
+ _ra_optElfunc[<?php echo $optionId; ?>][1] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']").onchange;
579
+ _ra_optElfunc[<?php echo $optionId; ?>][2] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']").onchange;
580
+ document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']").onchange = function () {
581
+ if (_ra_optElfunc[<?php echo $optionId; ?>][0] !== null) _ra_optElfunc[<?php echo $optionId; ?>][0]();
582
+ _ra_triggerSetVariation();
583
+ };
584
+ document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']").onchange = function () {
585
+ if (_ra_optElfunc[<?php echo $optionId; ?>][1] !== null) _ra_optElfunc[<?php echo $optionId; ?>][1]();
586
+ _ra_triggerSetVariation();
587
+ };
588
+ document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']").onchange = function () {
589
+ if (_ra_optElfunc[<?php echo $optionId; ?>][2] !== null) _ra_optElfunc[<?php echo $optionId; ?>][2]();
590
+ _ra_triggerSetVariation();
591
+ };
592
+ }
593
+ <?php endif ?>
594
+
595
+ <?php if ( $optionType == "file" ) : ?>
596
+ if (document.querySelector("input[type='file'].product-custom-option[name='options_<?php echo $optionId; ?>_file']") !== null) {
597
+ _ra_optElfunc[<?php echo $optionId; ?>] = document.querySelector("input[type='file'].product-custom-option[name='options_<?php echo $optionId; ?>_file']").onchange;
598
+ document.querySelector("input[type='file'].product-custom-option[name='options_<?php echo $optionId; ?>_file']").onchange = function () {
599
+ if (_ra_optElfunc[<?php echo $optionId; ?>] !== null) _ra_optElfunc[<?php echo $optionId; ?>]();
600
+ _ra_triggerSetVariation();
601
+ };
602
+ }
603
+ <?php endif ?>
604
+
605
+ <?php endforeach ?>
606
+ });
607
+ <?php endif ?>
608
+
609
+
610
+
611
+ <?php /*is not configurable*/ ?>
612
+ <?php else : ?>
613
+ <?php /*is configurable*/ ?>
614
+ /*configurable product..*/
615
+ <?php $_productAttributeOptions = $_product->getTypeInstance(true)->getConfigurableAttributesAsArray($_product); ?>
616
+ <?php if ( count($_productAttributeOptions) > 0 ) : ?>
617
+
618
+ function _ra_triggerSetVariation() {
619
+ var _ra_variation = _ra_grabVariation();
620
+ if (typeof _ra.setVariation !== "undefined") {
621
+ _ra.setVariation("<?php echo $_product->getId(); ?>", _ra_variation);
622
+ }
623
+ }
624
+
625
+ _ra_optElfunc = [];
626
+
627
+ function _ra_grabVariation() {
628
+ var _ra_vo = {};
629
+ var _ra_voCode = [];
630
+ var _ra_voDetails = {};
631
+
632
+ <?php foreach ($_productAttributeOptions as $_productAttribute) : ?>
633
+ <?php $attributeId = $_productAttribute["attribute_id"]; ?>
634
+ <?php $attributeTitle = $_productAttribute["label"]; ?>
635
+ if (document.getElementById("attribute<?php echo $attributeId; ?>") !== null) {
636
+ _ra_voCode.push(document.getElementById("attribute<?php echo $attributeId; ?>").options[document.getElementById("attribute<?php echo $attributeId; ?>").selectedIndex].text);
637
+ }
638
+ _ra_voDetails[_ra_voCode[_ra_voCode.length - 1].replace(RegExp("[- ]", 'g'), '')] = {
639
+ "category_name": "<?php echo $attributeTitle; ?>",
640
+ "category": "<?php echo $attributeTitle; ?>",
641
+ "value": _ra_voCode[_ra_voCode.length - 1]
642
+ };
643
+ _ra_voCode[_ra_voCode.length - 1] = _ra_voCode[_ra_voCode.length - 1].replace(RegExp("[- ]", 'g'), '');
644
+ <?php endforeach ?>
645
+
646
+ var _ra_vo = {
647
+ "code": _ra_voCode.join('-'),
648
+ "stock": 1,
649
+ "details": _ra_voDetails
650
+ };
651
+
652
+ return _ra_vo;
653
+ }
654
+
655
+ _ra_helper_addLoadEvent(function () {
656
+ <?php foreach ($_productAttributeOptions as $_productAttribute) : ?>
657
+ <?php $attributeId = $_productAttribute["attribute_id"]; ?>
658
+ <?php $attributeTitle = $_productAttribute["label"]; ?>
659
+ if (document.getElementById("attribute<?php echo $attributeId; ?>") !== null) {
660
+ _ra_optElfunc[<?php echo $attributeId; ?>] = document.getElementById("attribute<?php echo $attributeId; ?>").onchange;
661
+ document.getElementById("attribute<?php echo $attributeId; ?>").onchange = function () {
662
+ if (_ra_optElfunc[<?php echo $attributeId; ?>] !== null) _ra_optElfunc[<?php echo $attributeId; ?>]();
663
+ _ra_triggerSetVariation();
664
+ };
665
+ }
666
+ <?php endforeach ?>
667
+ });
668
+
669
+ <?php endif ?>
670
+
671
+ <?php /*is configurable*/ ?>
672
+ <?php endif ?>
673
+
674
+
675
+ <?php endif ?>
676
+ <?php endif ?>
677
+ <?php endif //magento version ?>
678
+
679
+
680
+ <?php
681
+ /*
682
+ ----------------------- Trigger addToWishlist -----------------------
683
+ */
684
+ ?>
685
+ <?php if ( $info = Mage::getSingleton('core/session')->getTriggerAddToWishlist() ) : ?>
686
+
687
+ // Trigger addToWishlist
688
+
689
+ <?php $referral = Mage::getSingleton('core/session')->getReferralController(); echo "/*" . $referral . "*/"; ?>
690
+ <?php if ( $referral != "product" ) : ?>
691
+
692
+ // Trigger sendProduct before addToWishlist
693
+
694
+ <?php
695
+ $_product = Mage::getModel('catalog/product')->load($info['product_id']);
696
+ $_productUrl = $_product->getProductUrl();
697
+ $_category = false;
698
+
699
+ $_productCategoryIds = $_product->getCategoryIds();
700
+ if (count($_productCategoryIds)) {
701
+ $firstCategoryId = $_productCategoryIds[0];
702
+ $_category = Mage::getModel('catalog/category')->load($firstCategoryId);
703
+ }
704
+
705
+ $_categoryParent = "false";
706
+ $_categoryBreadcrumb = "[]";
707
+
708
+ if ($_category) {
709
+ if ($_category->getLevel() > 2) {
710
+ $_categoryParent = '"' . $_category->getParentId() . '"';
711
+ $_categoryBreadcrumb = array();
712
+ $breadcrumbCategory = $_category;
713
+ while ($breadcrumbCategory->getLevel() > 2) {
714
+ $breadcrumbCategory = Mage::getModel('catalog/category')->load($breadcrumbCategory->getParentId());
715
+
716
+ $_categoryBreadcrumb[] = '{
717
+ "id": "' . $breadcrumbCategory->getId() . '",
718
+ "name": "' . htmlspecialchars($breadcrumbCategory->getName()) . '",
719
+ "parent": ' . ($breadcrumbCategory->getLevel() > 2 ? '"' . $breadcrumbCategory->getParentId() . '"' : 'false') . '
720
+ }';
721
+ }
722
+ $_categoryBreadcrumb = '[' . implode(', ', $_categoryBreadcrumb) . ']';
723
+ }
724
+ $_category = '[{
725
+ "id": "' . $_category->getId() . '",
726
+ "name": "' . htmlspecialchars($_category->getName()) . '",
727
+ "parent": ' . $_categoryParent . ',
728
+ "breadcrumb" : ' . $_categoryBreadcrumb . '}]';
729
+ } else {
730
+ $_category = '[{"id": "-1", "name": "no category", "parent": false}]';
731
+ }
732
+ ?>
733
+
734
+ var _ra = _ra || {};
735
+ _ra.sendProductInfo = {
736
+ "id": "<?php echo $_product->getId(); ?>",
737
+ "name": "<?php echo htmlspecialchars($_product->getName()); ?>",
738
+ "url": "<?php echo htmlspecialchars(strtok($_productUrl, '?')); ?>",
739
+ "img": "<?php echo htmlspecialchars(Mage::helper('catalog/image')->init($_product, 'image')->resize(500)); ?>",
740
+ "price": <?php echo Mage::helper('tax')->getPrice($_product, $_product->getPrice()); ?>,
741
+ "promo": <?php echo(Mage::helper('tax')->getPrice($_product, $_product->getPrice()) - Mage::helper('tax')->getPrice($_product, $_product->getFinalPrice()) > 0 ? Mage::helper('tax')->getPrice($_product, $_product->getFinalPrice()) : 0); ?>,
742
+ "inventory": {
743
+ "variations": false,
744
+ "stock": <?php echo $_product->getIsInStock() ?>
745
+ },
746
+ "brand": false,
747
+ "category": <?php echo $_category; ?>,
748
+ "callback_function": function () {
749
+ _ra.addToWishlistInfo = {
750
+ "product_id": "<?php echo $info['product_id']; ?>"
751
+ };
752
+ if (typeof _ra.addToWishlist !== "undefined") {
753
+ _ra.addToWishlist(_ra.addToWishlistInfo.product_id);
754
+ }
755
+ }
756
+ };
757
+
758
+ if (_ra.ready !== undefined) {
759
+ if (typeof _ra.sendProduct !== "undefined") {
760
+ _ra.sendProduct(_ra.sendProductInfo);
761
+ }
762
+ }
763
+
764
+ <?php else : ?>
765
+
766
+ var _ra = _ra || {};
767
+ _ra.addToWishlistInfo = {
768
+ "product_id": "<?php echo $info['product_id']; ?>"
769
+ };
770
+
771
+ if (_ra.ready !== undefined) {
772
+ if (typeof _ra.addToWishlist !== "undefined") {
773
+ _ra.addToWishlist(_ra.addToWishlistInfo.product_id);
774
+ }
775
+ }
776
+
777
+ <?php endif ?>
778
+
779
+ <?php Mage::getSingleton('core/session')->unsTriggerAddToWishlist(); ?>
780
+ <?php endif ?>
781
+
782
+
783
+
784
+ <?php
785
+ /*
786
+ ----------------------- Trigger clickImage -----------------------
787
+ */
788
+ ?>
789
+ <?php if ( Mage::app()->getFrontController()->getRequest()->getControllerName() == "product" && !is_null(Mage::registry('product')) ) : ?>
790
+
791
+ // Trigger clickImage
792
+
793
+ <?php
794
+ $_product = Mage::registry('current_product');
795
+ if($_product) :
796
+ ?>
797
+ <?php
798
+
799
+ $customClass = Mage::helper('retargeting_tracker')->getCustomClass();
800
+ if(Mage::helper('retargeting_tracker')->getCustomClass() != "") :
801
+ ?>
802
+
803
+ function _ra_triggerClickImage() {
804
+ if (typeof _ra.clickImage !== "undefined") {
805
+ _ra.clickImage("<?php echo $_product->getId(); ?>");
806
+ }
807
+ }
808
+ _ra_helper_addLoadEvent(function () {
809
+ if (document.getElementsByClassName("<?php echo $customClass ?>").length > 0) {
810
+ document.getElementsByClassName("<?php echo $customClass ?>")[0].onmouseover = _ra_triggerClickImage;
811
+ }
812
+ });
813
+ //custom css
814
+ <?php else : ?>
815
+ function _ra_triggerClickImage() {
816
+ if (typeof _ra.clickImage !== "undefined") {
817
+ _ra.clickImage("<?php echo $_product->getId(); ?>");
818
+ }
819
+ }
820
+
821
+ _ra_helper_addLoadEvent(function () {
822
+ if (document.getElementsByClassName("zoomWindow").length > 0) {
823
+ document.getElementsByClassName("zoomWindow")[0].onmouseover = _ra_triggerClickImage;
824
+ }
825
+ if (document.getElementsByClassName("zoomLens").length > 0) {
826
+ document.getElementsByClassName("zoomLens")[0].onmouseover = _ra_triggerClickImage;
827
+ }
828
+ if (document.getElementsByClassName("MagicToolboxContainer").length > 0) {
829
+ document.getElementsByClassName("MagicZoomBigImageCont")[0].onmouseover = _ra_triggerClickImage;
830
+ }
831
+ if (document.getElementById("image") !== null) {
832
+ document.getElementById("image").onclick = _ra_triggerClickImage;
833
+ } else if (document.querySelector(".product-image img") !== null) {
834
+ var el = document.querySelector(".product-image img").onclick = _ra_triggerClickImage;
835
+ }
836
+ });
837
+ <?php endif //customcss?>
838
  <?php endif //endif product ?>
839
+ <?php endif ?>
840
 
841
 
842
 
843
+ <?php
844
+ /*
845
+ ----------------------- Trigger commentOnProduct -----------------------
846
+ */
847
+ ?>
848
+ <?php if ( $info = Mage::getSingleton('core/session')->getTriggerCommentOnProduct() ) : ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
849
 
850
+ // Trigger commentOnProduct
851
 
852
+ var _ra = _ra || {};
853
+ _ra.commentOnProductInfo = {
854
+ "product_id": "<?php echo $info['product_id']; ?>"
855
+ };
856
 
857
+ if (_ra.ready !== undefined) {
858
+ if (typeof _ra.commentOnProduct !== "undefined") {
859
+ _ra.commentOnProduct(_ra.commentOnProductInfo.product_id);
860
+ }
861
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
862
 
863
+ <?php Mage::getSingleton('core/session')->unsTriggerCommentOnProduct(); ?>
864
+ <?php endif ?>
865
 
866
 
867
 
868
+ <?php
869
+ /*
870
+ ----------------------- Trigger mouseOverPrice -----------------------
871
+ */
872
+ ?>
873
+ <?php if ( Mage::app()->getFrontController()->getRequest()->getControllerName() == "product" && !is_null(Mage::registry('product')) ) : ?>
874
+
875
+ // Trigger mouseOverPrice
876
+
877
+ <?php $_product = Mage::registry('current_product'); ?>
878
+ <?php if($_product): ?>
879
+ function _ra_triggerMouseOverPrice() {
880
+ if (typeof _ra.mouseOverPrice !== "undefined") {
881
+ _ra.mouseOverPrice("<?php echo $_product->getId(); ?>", {
882
+ "price": <?php echo Mage::helper('tax')->getPrice($_product, $_product->getPrice()); ?>,
883
+ "promo": <?php echo(Mage::helper('tax')->getPrice($_product, $_product->getPrice()) - Mage::helper('tax')->getPrice($_product, $_product->getFinalPrice()) > 0 ? Mage::helper('tax')->getPrice($_product, $_product->getFinalPrice()) : 0); ?>
884
+ });
885
+ }
886
+ }
887
 
888
+ _ra_helper_addLoadEvent(function () {
889
+ if (document.getElementById("product-price-<?php echo $_product->getId(); ?>") !== null) {
890
+ document.getElementById("product-price-<?php echo $_product->getId(); ?>").onmouseover = _ra_triggerMouseOverPrice;
891
+ }
892
+ if (document.getElementById("old-price-<?php echo $_product->getId(); ?>") !== null) {
893
+ document.getElementById("old-price-<?php echo $_product->getId(); ?>").onmouseover = _ra_triggerMouseOverPrice;
894
+ }
895
+ });
896
 
897
+ <?php endif ?>
898
+ <?php endif ?>
 
 
 
899
 
 
 
 
 
 
 
 
900
 
 
 
901
 
902
+ <?php
903
+ /*
904
+ ----------------------- Trigger mouseOverAddToCart -----------------------
905
+ */
906
+ ?>
907
+ <?php if ( Mage::app()->getFrontController()->getRequest()->getControllerName() == "product" && !is_null(Mage::registry('product')) ) : ?>
908
 
909
+ // Trigger mouseOverAddToCart
910
 
911
+ <?php $_product = Mage::registry('current_product'); ?>
912
+ <?php if($_product): ?>
913
+ function _ra_triggerMouseOverAddToCart() {
914
+ if (typeof _ra.mouseOverAddToCart !== "undefined") {
915
+ _ra.mouseOverAddToCart("<?php echo $_product->getId(); ?>");
916
+ }
917
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
918
 
919
+ _ra_helper_addLoadEvent(function () {
920
+ if (document.getElementById("product-addtocart-button") !== null) {
921
+ document.getElementById("product-addtocart-button").onmouseover = _ra_triggerMouseOverAddToCart;
922
+ } else if (document.getElementsByClassName("btn-cart").length > 0) {
923
+ document.getElementsByClassName("btn-cart")[0].onmouseover = _ra_triggerMouseOverAddToCart;
924
+ }
925
+ });
926
 
927
+ <?php endif ?>
928
+ <?php endif ?>
929
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
930
 
931
 
932
+ <?php
933
+ /*
934
+ ----------------------- Trigger saveOrder -----------------------
935
+ */
936
+ ?>
937
+ <?php if ( $info = Mage::getSingleton('core/session')->getTriggerSaveOrder() ) : ?>
938
+
939
+ // Trigger saveOrder
940
+
941
+ var _ra = _ra || {};
942
+ _ra.saveOrderInfo = {
943
+ "order_no": "<?php echo $info['order_no']; ?>",
944
+ "lastname": "<?php echo htmlspecialchars($info['lastname']); ?>",
945
+ "firstname": "<?php echo htmlspecialchars($info['firstname']); ?>",
946
+ "email": "<?php echo htmlspecialchars($info['email']); ?>",
947
+ "phone": "<?php echo htmlspecialchars($info['phone']); ?>",
948
+ "state": "<?php echo htmlspecialchars($info['state']); ?>",
949
+ "city": "<?php echo htmlspecialchars($info['city']); ?>",
950
+ "address": "<?php echo htmlspecialchars($info['address']); ?>",
951
+ "discount": <?php echo $info['discount']; ?>,
952
+ "discount_code": "<?php echo $info['discount_code']; ?>",
953
+ "shipping": <?php echo $info['shipping']; ?>,
954
+ "total": <?php echo $info['total']; ?>,
955
+ };
956
+ _ra.saveOrderProducts = <?php echo $info['products']; ?>
957
 
958
+ if (_ra.ready !== undefined) {
959
+ if (typeof _ra.saveOrder !== "undefined") {
960
+ _ra.saveOrder(_ra.saveOrderInfo, _ra.saveOrderProducts);
961
+ }
962
+ }
963
 
964
+ <?php Mage::getSingleton('core/session')->unsTriggerSaveOrder(); ?>
965
+ <?php endif ?>
966
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
967
 
 
968
 
969
+ <?php
970
+ /*
971
+ ----------------------- Trigger visitHelpPage -----------------------
972
+ */
973
+ ?>
974
+ <?php if ( Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms' ) : ?>
975
 
976
+ <?php
977
+ $page = Mage::getSingleton('cms/page');
978
+ $helpPages = Mage::getStoreConfig('retargetingtracker_options/more/help_pages');
979
+ $helpPages = explode(',', $helpPages);
980
+ ?>
981
+
982
+ <?php if ( $page->getId() && in_array($page->getId(), $helpPages) ) : ?>
983
+
984
+ // Trigger visitHelpPage
985
+
986
+ var _ra = _ra || {};
987
+ _ra.visitHelpPageInfo = {
988
+ "visit": true
989
+ }
990
+
991
+ if (_ra.ready !== undefined) {
992
+ if (typeof _ra.visitHelpPage !== "undefined") {
993
+ _ra.visitHelpPage();
994
+ }
995
+ }
996
+
997
+ <?php endif ?>
998
+
999
+
1000
+ <?php endif ?>
1001
+
1002
+
1003
+
1004
+ <?php
1005
+ /*
1006
+ ----------------------- Trigger checkoutIds -----------------------
1007
+ */
1008
+ ?>
1009
+ <?php
1010
+ $request = $this->getRequest();
1011
+ $module = $request->getModuleName();
1012
+ $controller = $request->getControllerName();
1013
+ $action = $request->getActionName();
1014
+ ?>
1015
+ <?php
1016
+ if ( ($module == 'checkout' && $controller == 'cart' && $action == 'index') || ($module == 'checkout' && $controller == 'onepage' && $action == 'index') || (Mage::getURL('checkout/onepage') == Mage::helper('core/url')->getCurrentUrl()) || (strrpos(Mage::helper('core/url')->getCurrentUrl(), "/onestepcheckout") !== false)
1017
+ ) : ?>
1018
+
1019
+ // Trigger checkoutIds
1020
 
1021
+ <?php
1022
+ $items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
1023
+ $products = array();
1024
+ foreach ($items as $item) {
1025
+ $products[] = $item->getProductId();
1026
+ }
1027
+ $products = implode(", ", $products);
1028
+ ?>
1029
+
1030
+ var _ra = _ra || {};
1031
+ _ra.checkoutIdsInfo = [<?php echo $products; ?>];
1032
+
1033
+ if (_ra.ready !== undefined) {
1034
+ if (typeof _ra.checkoutIds !== "undefined") {
1035
+ _ra.checkoutIds(_ra.checkoutIdsInfo);
1036
+ }
1037
+ }
1038
+
1039
+ <?php endif ?>
1040
+
1041
+
1042
+ <?php // likeFacebook
1043
+ $_product = Mage::registry('current_product');
1044
+ if($_product && Mage::helper('retargeting_tracker')->isFacebookAvailable()) :
1045
+ ?>
1046
+
1047
+ if (typeof FB != "undefined") {
1048
+ FB.Event.subscribe('edge.create', function () {
1049
  _ra.likeFacebook(<?php echo $_product->getId()?>);
1050
  });
1051
+ }
1052
+ <?php endif; //end like facebook ?>
1053
 
1054
  </script>
1055
  <?php
1058
  */
1059
  ?>
1060
  <?php
1061
+ Mage::getSingleton('core/session')->setReferralController(Mage::app()->getFrontController()->getRequest()->getControllerName());
1062
  ?>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Retargeting_Tracker</name>
4
- <version>1.2.6</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>CheckoutIds hotfix</notes>
31
  <authors><author><name>Retargeting Team</name><user>retargeting</user><email>info@retargeting.biz</email></author></authors>
32
- <date>2016-07-26</date>
33
- <time>15:06:18</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="2a5e9ec6f943e93c6db0b1571b27e5b2"/></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="ce47f53b673208251218699de77cda5e"/><file name="system.xml" hash="a9355f6a0d87bed6fb48d73db9646a41"/></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="61395cd9bcc55a21807f627b8d108aac"/><file name="triggers.phtml" hash="aaa7f44819fed1c8cf71835a17e9dfb7"/></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.1.0</min><max>6.0.0</max></php></required></dependencies>
37
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Retargeting_Tracker</name>
4
+ <version>1.2.7</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>Bugfixes</notes>
31
  <authors><author><name>Retargeting Team</name><user>retargeting</user><email>info@retargeting.biz</email></author></authors>
32
+ <date>2016-08-01</date>
33
+ <time>13:27:44</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="2a5e9ec6f943e93c6db0b1571b27e5b2"/></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="0811ecc9794124c37e42e284268640fc"/><file name="system.xml" hash="a9355f6a0d87bed6fb48d73db9646a41"/></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="3db94a082eab6e4659463055bff0ebbc"/></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.1.0</min><max>6.0.0</max></php></required></dependencies>
37
  </package>