Version Notes
Retargeting V3
Download this release
Release Info
| Developer | Retargeting Team |
| Extension | Retargeting_Tracker |
| Version | 1.2.1 |
| Comparing to | |
| See all releases | |
Code changes from version 1.2.0 to 1.2.1
- app/code/community/Retargeting/.DS_Store +0 -0
- app/code/community/Retargeting/Tracker/.DS_Store +0 -0
- app/code/community/Retargeting/Tracker/etc/config.xml +1 -1
- app/design/frontend/base/default/layout/retargeting_tracker.xml +14 -0
- app/design/frontend/base/default/template/retargeting_tracker/embed.phtml +33 -0
- app/design/frontend/base/default/template/retargeting_tracker/triggers.phtml +1016 -0
- lib/Retargeting/Retargeting_REST_API_Client.php +198 -0
- package.xml +3 -3
app/code/community/Retargeting/.DS_Store
CHANGED
|
Binary file
|
app/code/community/Retargeting/Tracker/.DS_Store
CHANGED
|
Binary file
|
app/code/community/Retargeting/Tracker/etc/config.xml
CHANGED
|
@@ -11,7 +11,7 @@
|
|
| 11 |
<config>
|
| 12 |
<modules>
|
| 13 |
<Retargeting_Tracker>
|
| 14 |
-
<version>1.2.
|
| 15 |
</Retargeting_Tracker>
|
| 16 |
</modules>
|
| 17 |
<global>
|
| 11 |
<config>
|
| 12 |
<modules>
|
| 13 |
<Retargeting_Tracker>
|
| 14 |
+
<version>1.2.1</version>
|
| 15 |
</Retargeting_Tracker>
|
| 16 |
</modules>
|
| 17 |
<global>
|
app/design/frontend/base/default/layout/retargeting_tracker.xml
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<layout version="0.1.0">
|
| 3 |
+
<default>
|
| 4 |
+
|
| 5 |
+
<reference name="head">
|
| 6 |
+
<block type="retargeting_tracker/embed" name="retargeting.embed" template="retargeting_tracker/embed.phtml"/>
|
| 7 |
+
</reference>
|
| 8 |
+
|
| 9 |
+
<reference name="head">
|
| 10 |
+
<block type="retargeting_tracker/triggers" name="retargeting.triggers" template="retargeting_tracker/triggers.phtml"/>
|
| 11 |
+
</reference>
|
| 12 |
+
|
| 13 |
+
</default>
|
| 14 |
+
</layout>
|
app/design/frontend/base/default/template/retargeting_tracker/embed.phtml
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* @category Retargeting
|
| 4 |
+
* @package Retargeting_Tracker
|
| 5 |
+
* @author Retargeting <info@retargeting.biz>
|
| 6 |
+
* @copyright Copyright (c) Retargeting
|
| 7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 8 |
+
*/
|
| 9 |
+
?>
|
| 10 |
+
<script type="text/javascript">
|
| 11 |
+
<?php
|
| 12 |
+
$ra_key = Mage::getStoreConfig('retargetingtracker_options/domain/domain_api_key');
|
| 13 |
+
$add_to_cart_id = Mage::getStoreConfig('retargetingtracker_options/more/cartid');
|
| 14 |
+
$price_label_id = Mage::getStoreConfig('retargetingtracker_options/more/pricelabelid');
|
| 15 |
+
?>
|
| 16 |
+
<?php if ($ra_key && $ra_key != '') : ?>
|
| 17 |
+
(function(){
|
| 18 |
+
ra_key = "<?php echo $ra_key; ?>";
|
| 19 |
+
ra_params = {
|
| 20 |
+
add_to_cart_button_id: "<?php echo ($add_to_cart_id != '' && $add_to_cart_id) ? $add_to_cart_id : "add-to-cart-buttons" ?>",
|
| 21 |
+
price_label_id: "<?php echo ($price_label_id != '' && $price_label_id) ? $price_label_id : "price-box" ?>",
|
| 22 |
+
};
|
| 23 |
+
var ra = document.createElement("script"); ra.type ="text/javascript"; ra.async = true; ra.src = ("https:" ==
|
| 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>
|
app/design/frontend/base/default/template/retargeting_tracker/triggers.phtml
ADDED
|
@@ -0,0 +1,1016 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* @category Retargeting
|
| 4 |
+
* @package Retargeting_Tracker
|
| 5 |
+
* @author Retargeting <info@retargeting.biz>
|
| 6 |
+
* @copyright Copyright (c) Retargeting
|
| 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 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) ) : ?>
|
| 974 |
+
|
| 975 |
+
// Trigger checkoutIds
|
| 976 |
+
|
| 977 |
+
<?php
|
| 978 |
+
$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
|
| 979 |
+
$products = array();
|
| 980 |
+
foreach($items as $item) {
|
| 981 |
+
$products[] = $item->getProductId();
|
| 982 |
+
}
|
| 983 |
+
$products = implode(", ", $products);
|
| 984 |
+
?>
|
| 985 |
+
|
| 986 |
+
var _ra = _ra || {};
|
| 987 |
+
_ra.checkoutIdsInfo = [<?php echo $products; ?>];
|
| 988 |
+
|
| 989 |
+
if (_ra.ready !== undefined) {
|
| 990 |
+
if(typeof _ra.checkoutIds !== "undefined") _ra.checkoutIds(_ra.checkoutIdsInfo);
|
| 991 |
+
}
|
| 992 |
+
|
| 993 |
+
<?php endif ?>
|
| 994 |
+
|
| 995 |
+
|
| 996 |
+
<?php // likeFacebook
|
| 997 |
+
$_product = Mage::registry('current_product');
|
| 998 |
+
if($_product && Mage::helper('retargeting_tracker')->isFacebookAvailable()) :
|
| 999 |
+
?>
|
| 1000 |
+
|
| 1001 |
+
if (typeof FB != "undefined") {
|
| 1002 |
+
FB.Event.subscribe('edge.create', function () {
|
| 1003 |
+
_ra.likeFacebook(<?php echo $_product->getId()?>);
|
| 1004 |
+
});
|
| 1005 |
+
};
|
| 1006 |
+
<?php endif; //end like facebook ?>
|
| 1007 |
+
|
| 1008 |
+
</script>
|
| 1009 |
+
<?php
|
| 1010 |
+
/*
|
| 1011 |
+
----------------------- Track URL History --------------------------
|
| 1012 |
+
*/
|
| 1013 |
+
?>
|
| 1014 |
+
<?php
|
| 1015 |
+
Mage::getSingleton('core/session')->setReferralController( Mage::app()->getFrontController()->getRequest()->getControllerName() );
|
| 1016 |
+
?>
|
lib/Retargeting/Retargeting_REST_API_Client.php
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Class: Retargeting REST API Client
|
| 4 |
+
*/
|
| 5 |
+
class Retargeting_REST_API_Client
|
| 6 |
+
{
|
| 7 |
+
/**
|
| 8 |
+
* Property: the uniform resource identifier for the current web request
|
| 9 |
+
* @var string
|
| 10 |
+
*/
|
| 11 |
+
protected $api_uri = "https://retargeting.ro/api";
|
| 12 |
+
|
| 13 |
+
/**
|
| 14 |
+
* Property: the API version
|
| 15 |
+
* @var string
|
| 16 |
+
*/
|
| 17 |
+
protected $api_version = "1.0";
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* Property: the API response format: json or serial (php serialize)
|
| 21 |
+
* @var string
|
| 22 |
+
*/
|
| 23 |
+
protected $response_format = "json";
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* Property: if is true the response from API request will be decoded (for json response format) / converted (for serial response format)
|
| 27 |
+
* @var boolean
|
| 28 |
+
*/
|
| 29 |
+
protected $decoding = true;
|
| 30 |
+
|
| 31 |
+
/**
|
| 32 |
+
* Property: the API KEY
|
| 33 |
+
* @see Retargeting Administration Panel
|
| 34 |
+
* @var unknown
|
| 35 |
+
*/
|
| 36 |
+
private $api_key = "";
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
* Property: the USER TOKEN
|
| 40 |
+
* @see Retargeting Administration Panel
|
| 41 |
+
* @var unknown
|
| 42 |
+
*/
|
| 43 |
+
private $user_token = "";
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* Property: the API request path (/api/path)
|
| 47 |
+
* @var array
|
| 48 |
+
*/
|
| 49 |
+
private $api_path = array();
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* Property: the API request parameters
|
| 53 |
+
* @var array
|
| 54 |
+
*/
|
| 55 |
+
private $api_parameters = array();
|
| 56 |
+
|
| 57 |
+
/**
|
| 58 |
+
* Method: constructor method for Retargeting REST API Client class
|
| 59 |
+
* @param string $api_key
|
| 60 |
+
* @param mixed $user_token
|
| 61 |
+
*/
|
| 62 |
+
public function __construct($api_key, $user_token) {
|
| 63 |
+
if (is_string($api_key) || is_numeric($api_key)) {
|
| 64 |
+
$this->api_key = $api_key;
|
| 65 |
+
} else {
|
| 66 |
+
$this->_throwException("checkApiKey");
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
if (is_string($user_token) || is_numeric($user_token)) {
|
| 70 |
+
$this->user_token = $user_token;
|
| 71 |
+
} else {
|
| 72 |
+
$this->_throwException("checkUserToken");
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
/**
|
| 77 |
+
* Method: set a new API uri
|
| 78 |
+
* @param string $api_uri
|
| 79 |
+
*/
|
| 80 |
+
public function setApiUri($api_uri) {
|
| 81 |
+
if (is_string($api_uri) && !empty($api_uri)) {
|
| 82 |
+
$this->api_uri = $api_uri;
|
| 83 |
+
} else {
|
| 84 |
+
$this->_throwException("apiUriType");
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
/**
|
| 89 |
+
* Method: set a new API version
|
| 90 |
+
* @param string $api_version
|
| 91 |
+
*/
|
| 92 |
+
public function setApiVersion($api_version) {
|
| 93 |
+
if (is_string($api_version) && !empty($api_version)) {
|
| 94 |
+
$this->api_version = $api_version;
|
| 95 |
+
} else {
|
| 96 |
+
$this->_throwException("apiVersionType");
|
| 97 |
+
}
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
/**
|
| 101 |
+
* Method: set a new API response format: json or serial (php serialize)
|
| 102 |
+
* @param string $response_format
|
| 103 |
+
*/
|
| 104 |
+
public function setResponseFormat($response_format = "json") {
|
| 105 |
+
if (in_array($response_format, array("json", "serial"))) {
|
| 106 |
+
$this->response_format = $response_format;
|
| 107 |
+
} else {
|
| 108 |
+
$this->_throwException("responseFormat");
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
public function setDecoding($mode = true) {
|
| 113 |
+
if (is_bool($mode)) {
|
| 114 |
+
$this->decoding = $mode;
|
| 115 |
+
} else {
|
| 116 |
+
$this->_throwException("decodingMode");
|
| 117 |
+
}
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
/**
|
| 121 |
+
* Overloading method: is utilized for reading data from inaccessible properties
|
| 122 |
+
* @param string $name
|
| 123 |
+
* @return Retargeting_REST_API_Client
|
| 124 |
+
*/
|
| 125 |
+
public function __get($name) {
|
| 126 |
+
$this->api_path[] = $name;
|
| 127 |
+
return $this;
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
/**
|
| 131 |
+
* Overloading method: is triggered when invoking inaccessible methods in an object context
|
| 132 |
+
* @param string $name
|
| 133 |
+
* @param array $arguments
|
| 134 |
+
* @see _processRequest()
|
| 135 |
+
* @return array
|
| 136 |
+
*/
|
| 137 |
+
public function __call($name, $arguments) {
|
| 138 |
+
$this->api_path[] = $name;
|
| 139 |
+
$this->api_parameters = $arguments;
|
| 140 |
+
return $this->_processRequest();
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
/**
|
| 144 |
+
* Method: use PHP cURL library to connect with Retargeting REST API and send the request
|
| 145 |
+
* @see http://php.net/manual/ro/book.curl.php
|
| 146 |
+
* @return array
|
| 147 |
+
*/
|
| 148 |
+
private function _processRequest() {
|
| 149 |
+
if (empty($this->api_path)) {
|
| 150 |
+
$this->_throwException("emptyApiPath");
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
$api_uri = $this->api_uri."/".$this->api_version."/".implode("/", $this->api_path).".".$this->response_format;
|
| 154 |
+
$this->api_path = array();
|
| 155 |
+
|
| 156 |
+
$api_parameters = array(
|
| 157 |
+
"api_key" => $this->api_key,
|
| 158 |
+
"token" => $this->user_token
|
| 159 |
+
);
|
| 160 |
+
$api_parameters = http_build_query(array_merge($api_parameters, $this->api_parameters));
|
| 161 |
+
$this->api_parameters = array();
|
| 162 |
+
|
| 163 |
+
$curl_request = curl_init();
|
| 164 |
+
curl_setopt($curl_request, CURLOPT_URL, $api_uri);
|
| 165 |
+
curl_setopt($curl_request, CURLOPT_POST, true);
|
| 166 |
+
curl_setopt($curl_request, CURLOPT_POSTFIELDS, $api_parameters);
|
| 167 |
+
curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, true);
|
| 168 |
+
curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false);
|
| 169 |
+
|
| 170 |
+
if ($this->decoding) {
|
| 171 |
+
if ($this->response_format == "json") {
|
| 172 |
+
return json_decode(curl_exec($curl_request), true);
|
| 173 |
+
} elseif ($this->response_format == "serial") {
|
| 174 |
+
return unserialize(curl_exec($curl_request));
|
| 175 |
+
}
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
return curl_exec($curl_request);
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
/**
|
| 182 |
+
* Method: throw new exception with custom message
|
| 183 |
+
* @param string $message
|
| 184 |
+
* @throws Exception
|
| 185 |
+
*/
|
| 186 |
+
private function _throwException($message) {
|
| 187 |
+
$messages = array(
|
| 188 |
+
"checkApiKey" => "You need an API KEY to use Retargeting API. Please go to your Retargeting Administration Panel to set or check your API KEY.",
|
| 189 |
+
"checkUserToken" => "You need your USER TOKEN to use Retargeting API. Please go to your Retargeting Administration Panel to check your USER TOKEN.",
|
| 190 |
+
"apiUriType" => "The API uri must be string",
|
| 191 |
+
"apiVersionType" => "The API version must be string",
|
| 192 |
+
"responseFormat" => "The response format can be json or serial (php serialize)",
|
| 193 |
+
"decodingMode" => "Decoding must be boolean",
|
| 194 |
+
"emptyApiPath" => "You API request"
|
| 195 |
+
);
|
| 196 |
+
throw new Exception($messages[$message]);
|
| 197 |
+
}
|
| 198 |
+
}
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Retargeting_Tracker</name>
|
| 4 |
-
<version>1.2.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>Open Software License (OSL)</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -30,8 +30,8 @@
|
|
| 30 |
<notes>Retargeting V3</notes>
|
| 31 |
<authors><author><name>Retargeting Team</name><user>retargeting</user><email>info@retargeting.biz</email></author></authors>
|
| 32 |
<date>2016-05-25</date>
|
| 33 |
-
<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="39967db79a6c206dcc7baeb19188dd67"/></dir><dir name="controllers"><file name="DiscountsController.php" hash="0d6c4bf8da7cbb8becde6091c959d797"/><file name="IndexController.php" hash="9cbd5b979859b2014c5ed191d9b5686a"/><file name="ProductsController.php" hash="f2f556aee8c80f3a77a884792520102a"/></dir><dir name="etc"><file name="config.xml" hash="
|
| 35 |
<compatible/>
|
| 36 |
<dependencies><required><php><min>5.2.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.1</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>Open Software License (OSL)</license>
|
| 7 |
<channel>community</channel>
|
| 30 |
<notes>Retargeting V3</notes>
|
| 31 |
<authors><author><name>Retargeting Team</name><user>retargeting</user><email>info@retargeting.biz</email></author></authors>
|
| 32 |
<date>2016-05-25</date>
|
| 33 |
+
<time>12:23:35</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="39967db79a6c206dcc7baeb19188dd67"/></dir><dir name="controllers"><file name="DiscountsController.php" hash="0d6c4bf8da7cbb8becde6091c959d797"/><file name="IndexController.php" hash="9cbd5b979859b2014c5ed191d9b5686a"/><file name="ProductsController.php" hash="f2f556aee8c80f3a77a884792520102a"/></dir><dir name="etc"><file name="config.xml" hash="522b858c0789dc4fdcd203ff35c97637"/><file name="system.xml" hash="a9355f6a0d87bed6fb48d73db9646a41"/><file name=".DS_Store" hash="4eebcbc7406e8fc6848f48e3759208c3"/></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><file name=".DS_Store" hash="5cfb88e8662749c3158b53a5edf8b7f1"/></dir><file name=".DS_Store" hash="5c3161bd671b34271d057a3cf67d9ed4"/></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="69ca1957ffad152904acf110bb4d9bac"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Retargeting_Tracker.xml" hash="44dbbcea34bc8ed9cc6d744176adb9a6"/></dir></target><target name="magelib"><dir name="Retargeting"><file name="Retargeting_REST_API_Client.php" hash="fd92942d4feb817768bb8157c01c7138"/></dir></target></contents>
|
| 35 |
<compatible/>
|
| 36 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 37 |
</package>
|
