Version Notes
Retargeting
Download this release
Release Info
| Developer | Retargeting Team |
| Extension | Retargeting_Tracker |
| Version | 1.0.0 |
| Comparing to | |
| See all releases | |
Version 1.0.0
- app/code/community/Retargeting/Tracker/Block/Embed.php +13 -0
- app/code/community/Retargeting/Tracker/Block/Triggers.php +13 -0
- app/code/community/Retargeting/Tracker/Helper/Data.php +13 -0
- app/code/community/Retargeting/Tracker/Model/Helppages.php +22 -0
- app/code/community/Retargeting/Tracker/Model/Observer.php +189 -0
- app/code/community/Retargeting/Tracker/controllers/DiscountsController.php +139 -0
- app/code/community/Retargeting/Tracker/controllers/IndexController.php +15 -0
- app/code/community/Retargeting/Tracker/etc/config.xml +141 -0
- app/code/community/Retargeting/Tracker/etc/system.xml +86 -0
- app/code/community/Retargeting/Tracker/sql/retargeting_tracker_setup/mysql4-install-1.0.0.php +27 -0
- app/design/frontend/base/default/layout/retargeting_tracker.xml +14 -0
- app/design/frontend/base/default/template/retargeting_tracker/embed.phtml +17 -0
- app/design/frontend/base/default/template/retargeting_tracker/triggers.phtml +985 -0
- app/etc/modules/Retargeting_Tracker.xml +18 -0
- package.xml +37 -0
app/code/community/Retargeting/Tracker/Block/Embed.php
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
class Retargeting_Tracker_Block_Embed extends Mage_Core_Block_Template
|
| 11 |
+
{
|
| 12 |
+
|
| 13 |
+
}
|
app/code/community/Retargeting/Tracker/Block/Triggers.php
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
class Retargeting_Tracker_Block_Triggers extends Mage_Core_Block_Template
|
| 11 |
+
{
|
| 12 |
+
|
| 13 |
+
}
|
app/code/community/Retargeting/Tracker/Helper/Data.php
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
class Retargeting_Tracker_Helper_Data extends Mage_Core_Helper_Abstract
|
| 11 |
+
{
|
| 12 |
+
|
| 13 |
+
}
|
app/code/community/Retargeting/Tracker/Model/Helppages.php
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
class Retargeting_Tracker_Model_Helppages
|
| 11 |
+
{
|
| 12 |
+
public function toOptionArray()
|
| 13 |
+
{
|
| 14 |
+
$pageCollection = Mage::getModel('cms/page')->getCollection();
|
| 15 |
+
$pages = array();
|
| 16 |
+
foreach ($pageCollection as $page) {
|
| 17 |
+
$pages[] = array('value'=>$page->getId(), 'label'=>Mage::helper('retargeting_tracker')->__($page->getTitle()));
|
| 18 |
+
}
|
| 19 |
+
return $pages;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
}
|
app/code/community/Retargeting/Tracker/Model/Observer.php
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
class Retargeting_Tracker_Model_Observer
|
| 11 |
+
{
|
| 12 |
+
/*
|
| 13 |
+
public function catalogProductLoadAfter(Varien_Event_Observer $observer)
|
| 14 |
+
{
|
| 15 |
+
$product = $observer->getEvent()->getProduct();
|
| 16 |
+
}
|
| 17 |
+
*/
|
| 18 |
+
|
| 19 |
+
public function TrackSetEmail($observer)
|
| 20 |
+
{
|
| 21 |
+
$event = $observer->getEvent(); //Fetches the current event
|
| 22 |
+
$customer = $observer->getCustomer();
|
| 23 |
+
$customerPhone = '';
|
| 24 |
+
$customerCity = '';
|
| 25 |
+
|
| 26 |
+
$customerAddressId = $customer->getDefaultShipping();
|
| 27 |
+
if ($customerAddressId)
|
| 28 |
+
{
|
| 29 |
+
$address = Mage::getModel('customer/address')->load($customerAddressId);
|
| 30 |
+
$cust_data = $address->getData();
|
| 31 |
+
$customerPhone = $cust_data['telephone'];
|
| 32 |
+
$customerCity = $cust_data['city'];
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
$info = array(
|
| 37 |
+
"email" => $customer->getEmail(),
|
| 38 |
+
"name" => $customer->getName(),
|
| 39 |
+
"phone" => $customerPhone,
|
| 40 |
+
"city" => $customerCity,
|
| 41 |
+
"sex" => $customer->getGender()
|
| 42 |
+
);
|
| 43 |
+
|
| 44 |
+
Mage::getSingleton('core/session')->setTriggerSetEmail($info);
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
public function TrackAddToCart($observer)
|
| 48 |
+
{
|
| 49 |
+
$helper = Mage::helper('catalog/product_configuration');
|
| 50 |
+
|
| 51 |
+
$event = $observer->getEvent(); //Fetches the current event
|
| 52 |
+
$product = $event->getProduct();
|
| 53 |
+
$quoteItem = $event->getQuoteItem();
|
| 54 |
+
|
| 55 |
+
$optionsCode = array();
|
| 56 |
+
$optionsDetails = array();
|
| 57 |
+
$options = "false";
|
| 58 |
+
|
| 59 |
+
if ( ! $product->isConfigurable() && ! $product->isGrouped() ) {
|
| 60 |
+
$itemOptions = $helper->getOptions($quoteItem);
|
| 61 |
+
if ( count($itemOptions) > 0 ) {
|
| 62 |
+
foreach ($itemOptions as $itemOption) {
|
| 63 |
+
$_optCode = str_replace(' ', '', $itemOption['value']);
|
| 64 |
+
$_optCode = str_replace('-', '', $_optCode);
|
| 65 |
+
$_optCode = strip_tags($_optCode);
|
| 66 |
+
$optionsCode[] = $_optCode;
|
| 67 |
+
$optionsDetails[] = '"'.$_optCode.'": {
|
| 68 |
+
"category_name": "'.htmlspecialchars($itemOption['label']).'",
|
| 69 |
+
"category": "'.htmlspecialchars($itemOption['label']).'",
|
| 70 |
+
"value": "'.htmlspecialchars($itemOption['value']).'"
|
| 71 |
+
}';
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
} else {
|
| 75 |
+
$itemOptions = $helper->getOptions($event);
|
| 76 |
+
if ( count($itemOptions) > 0 ) {
|
| 77 |
+
foreach ($itemOptions as $itemOption) {
|
| 78 |
+
$_optCode = str_replace(' ', '', $itemOption['value']);
|
| 79 |
+
$_optCode = str_replace('-', '', $_optCode);
|
| 80 |
+
$_optCode = strip_tags($_optCode);
|
| 81 |
+
$optionsCode[] = $_optCode;
|
| 82 |
+
$optionsDetails[] = '"'.$_optCode.'": {
|
| 83 |
+
"category_name": "'.htmlspecialchars($itemOption['label']).'",
|
| 84 |
+
"category": "'.htmlspecialchars($itemOption['label']).'",
|
| 85 |
+
"value": "'.htmlspecialchars($itemOption['value']).'"
|
| 86 |
+
}';
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
if(count($optionsCode) > 0) $options = '{ "code": "'.implode('-', $optionsCode).'", "details": {'.implode(', ', $optionsDetails).'} }';
|
| 92 |
+
else $options = "false";
|
| 93 |
+
|
| 94 |
+
$info = array(
|
| 95 |
+
"product_id" => $product->getId(),
|
| 96 |
+
"variation" => $options
|
| 97 |
+
);
|
| 98 |
+
|
| 99 |
+
Mage::getSingleton('core/session')->setTriggerAddToCart($info);
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
public function TrackAddToWishlist($observer)
|
| 103 |
+
{
|
| 104 |
+
$event = $observer->getEvent(); //Fetches the current event
|
| 105 |
+
$product = $event->getProduct();
|
| 106 |
+
|
| 107 |
+
$info = array(
|
| 108 |
+
"product_id" => $product->getId()
|
| 109 |
+
);
|
| 110 |
+
|
| 111 |
+
Mage::getSingleton('core/session')->setTriggerAddToWishlist($info);
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
public function TrackCommentOnProduct($observer)
|
| 115 |
+
{
|
| 116 |
+
|
| 117 |
+
$object = $observer->getEvent()->getObject();
|
| 118 |
+
$productId = $object->getEntityPkValue();
|
| 119 |
+
|
| 120 |
+
$info = array(
|
| 121 |
+
"product_id" => $productId
|
| 122 |
+
);
|
| 123 |
+
|
| 124 |
+
Mage::getSingleton('core/session')->setTriggerCommentOnProduct($info);
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
public function TrackSaveOrder($observer)
|
| 128 |
+
{
|
| 129 |
+
$helper = Mage::helper('catalog/product_configuration');
|
| 130 |
+
|
| 131 |
+
$event = $observer->getEvent(); //Fetches the current event
|
| 132 |
+
$order = $observer->getOrder();
|
| 133 |
+
$shippingAddress = $order->getShippingAddress();
|
| 134 |
+
$quote = $observer->getEvent()->getQuote();
|
| 135 |
+
|
| 136 |
+
$products = array();
|
| 137 |
+
foreach ($order->getAllVisibleItems() as $item) {
|
| 138 |
+
$itemOptions = $item->getProductOptions();
|
| 139 |
+
$variationCode = "false";
|
| 140 |
+
$optionsCode = array();
|
| 141 |
+
|
| 142 |
+
$product = Mage::getModel('catalog/product')->load($item->getProductId());
|
| 143 |
+
if ( $product->isConfigurable() ) {
|
| 144 |
+
$_optCode = str_replace(' ', '', $item->getSku());
|
| 145 |
+
$_optCode = str_replace('-', '', $_optCode);
|
| 146 |
+
$_optCode = strip_tags($_optCode);
|
| 147 |
+
$optionsCode[] = $_optCode;
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
if ( count($itemOptions['options']) > 0 ) {
|
| 151 |
+
foreach ($itemOptions['options'] as $itemOption) {
|
| 152 |
+
$_optCode = str_replace(' ', '', $itemOption['value']);
|
| 153 |
+
$_optCode = str_replace('-', '', $_optCode);
|
| 154 |
+
$_optCode = strip_tags($_optCode);
|
| 155 |
+
$optionsCode[] = $_optCode;
|
| 156 |
+
}
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
$variationCode = count($optionsCode) > 0 ? '"'.implode('-', $optionsCode).'"' : "false";
|
| 160 |
+
|
| 161 |
+
$products[] = '{
|
| 162 |
+
"id": "'. $item->getProductId() .'",
|
| 163 |
+
"quantity": '. $item->getQtyOrdered() .',
|
| 164 |
+
"price": ' . Mage::helper('tax')->getPrice($item, $item->getPrice()).',
|
| 165 |
+
"variation_code": ' . $variationCode . '}';
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
$info = array(
|
| 169 |
+
"order_no" => $order->getIncrementId(),
|
| 170 |
+
"firstname" => $shippingAddress->getFirstname(),
|
| 171 |
+
"lastname" => $shippingAddress->getLastname(),
|
| 172 |
+
"email" => $shippingAddress->getEmail(),
|
| 173 |
+
"phone" => $shippingAddress->getTelephone(),
|
| 174 |
+
"state" => $shippingAddress->getRegion(),
|
| 175 |
+
"city" => $shippingAddress->getCity(),
|
| 176 |
+
"address" => implode(" ", $shippingAddress->getStreet()),
|
| 177 |
+
"data" => $shippingAddress->getData(),
|
| 178 |
+
"discount" => $order->getDiscountAmount(),
|
| 179 |
+
"discount_code" => '',
|
| 180 |
+
"shipping" => $order->getShippingInclTax(),
|
| 181 |
+
"total" => $order->getGrandTotal(),
|
| 182 |
+
"products" => "[".implode(",", $products)."]",
|
| 183 |
+
);
|
| 184 |
+
|
| 185 |
+
Mage::log($info, null, 'retargeting.log');
|
| 186 |
+
|
| 187 |
+
Mage::getSingleton('core/session')->setTriggerSaveOrder($info);
|
| 188 |
+
}
|
| 189 |
+
}
|
app/code/community/Retargeting/Tracker/controllers/DiscountsController.php
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
class Retargeting_Tracker_DiscountsController extends Mage_Core_Controller_Front_Action
|
| 11 |
+
{
|
| 12 |
+
public function indexAction() {
|
| 13 |
+
echo 'Discounts!!!';
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
public function addDiscountCodeAction() {
|
| 17 |
+
|
| 18 |
+
$params = $this->getRequest()->getParams();
|
| 19 |
+
|
| 20 |
+
if ( isset($params['apikey']) && isset($params['name']) && isset($params['code']) && isset($params['discount']) && isset($params['type']) && isset($params['condition']) && isset($params['availability']) && isset($params['condition_amount']) ) {
|
| 21 |
+
|
| 22 |
+
$userApiKey = Mage::getStoreConfig('retargetingtracker_options/discounts/discount_api_key');
|
| 23 |
+
|
| 24 |
+
if ( $userApiKey != '' && $params['apikey'] == $userApiKey && $params['name'] != "" && $params['code'] != "" && $params['discount'] != "" && $params['type'] != "" && $params['condition'] != "" && $params['availability'] != "" && $params['condition_amount'] != "" ) {
|
| 25 |
+
$name = htmlspecialchars($params['name']);
|
| 26 |
+
$code = htmlspecialchars($params['code']);
|
| 27 |
+
$discount = htmlspecialchars($params['discount']);
|
| 28 |
+
$type = htmlspecialchars($params['type']);
|
| 29 |
+
$condition = htmlspecialchars($params['condition']);
|
| 30 |
+
$availability = htmlspecialchars($params['availability']);
|
| 31 |
+
$conditionAmount = htmlspecialchars($params['condition_amount']);
|
| 32 |
+
|
| 33 |
+
echo $this->generateRule($name, $code, $discount, $type, $condition, $availability, $conditionAmount);
|
| 34 |
+
} else {
|
| 35 |
+
echo json_encode(array(
|
| 36 |
+
"status" => false,
|
| 37 |
+
"error" => "0002: Invalid Parameters!"
|
| 38 |
+
));
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
} else {
|
| 42 |
+
echo json_encode(array(
|
| 43 |
+
"status" => false,
|
| 44 |
+
"error" => "0001: Missing Parameters!"
|
| 45 |
+
));
|
| 46 |
+
}
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
private function generateRule($name = null, $coupon_code = null, $discount = 0, $type = "fixed value", $condition = null, $availability = 1, $conditionAmount = 0)
|
| 50 |
+
{
|
| 51 |
+
if ( $name != null && $coupon_code != null && ( $type == "fixed value" || $type == "free shipping" || $type == "percentage" ) )
|
| 52 |
+
{
|
| 53 |
+
$rule = Mage::getModel('salesrule/rule');
|
| 54 |
+
$customer_groups = array(0, 1, 2, 3);
|
| 55 |
+
|
| 56 |
+
// discount name and init
|
| 57 |
+
$rule->setName($name)
|
| 58 |
+
->setDescription("Autogenerated discount through Retargeting Discount API")
|
| 59 |
+
->setCouponType(2)
|
| 60 |
+
->setUsesPerCustomer(1)
|
| 61 |
+
->setUsesPerCoupon(1)
|
| 62 |
+
->setCustomerGroupIds($customer_groups) //an array of customer grou pids
|
| 63 |
+
->setIsActive(1)
|
| 64 |
+
->setConditionsSerialized('')
|
| 65 |
+
->setActionsSerialized('')
|
| 66 |
+
->setStopRulesProcessing(0)
|
| 67 |
+
->setIsAdvanced(1)
|
| 68 |
+
->setProductIds('')
|
| 69 |
+
->setSortOrder(0)
|
| 70 |
+
->setSimpleFreeShipping('0')
|
| 71 |
+
->setApplyToShipping('0')
|
| 72 |
+
->setIsRss(0)
|
| 73 |
+
->setWebsiteIds(array(1));
|
| 74 |
+
|
| 75 |
+
// discount code
|
| 76 |
+
$rule->setCouponCode($coupon_code);
|
| 77 |
+
|
| 78 |
+
// discount amount
|
| 79 |
+
$rule->setDiscountAmount($discount)
|
| 80 |
+
->setDiscountQty(null)
|
| 81 |
+
->setDiscountStep(0);
|
| 82 |
+
|
| 83 |
+
// discount type
|
| 84 |
+
switch ($type) {
|
| 85 |
+
case 'percentage':
|
| 86 |
+
$rule->setSimpleAction('by_percent');
|
| 87 |
+
break;
|
| 88 |
+
case 'free shipping':
|
| 89 |
+
$rule->setSimpleAction('by_fixed')
|
| 90 |
+
->setSimpleFreeShipping('1')
|
| 91 |
+
->setDiscountAmount(0);
|
| 92 |
+
break;
|
| 93 |
+
case 'fixed value':
|
| 94 |
+
$rule->setSimpleAction('by_fixed');
|
| 95 |
+
break;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
// discount availability
|
| 99 |
+
$rule->setFromDate(date('Y-m-d'))
|
| 100 |
+
->setToDate(Date('Y-m-d', strtotime("+".$availability." days")));
|
| 101 |
+
|
| 102 |
+
// discount conditions/actions
|
| 103 |
+
if ($condition == "over") {
|
| 104 |
+
$item_found = Mage::getModel('salesrule/rule_condition_product_found')
|
| 105 |
+
->setType('salesrule/rule_condition_product_found')
|
| 106 |
+
->setValue(1) // 1 == FOUND
|
| 107 |
+
->setAggregator('all'); // match ALL conditions
|
| 108 |
+
$rule->getConditions()->addCondition($item_found);
|
| 109 |
+
|
| 110 |
+
$conditions = Mage::getModel('salesrule/rule_condition_product')
|
| 111 |
+
->setType('salesrule/rule_condition_product')
|
| 112 |
+
->setAttribute('quote_item_price')
|
| 113 |
+
->setOperator('>=')
|
| 114 |
+
->setValue($conditionAmount);
|
| 115 |
+
$item_found->addCondition($conditions);
|
| 116 |
+
|
| 117 |
+
$actions = Mage::getModel('salesrule/rule_condition_product')
|
| 118 |
+
->setType('salesrule/rule_condition_product')
|
| 119 |
+
->setAttribute('quote_item_price')
|
| 120 |
+
->setOperator('>=')
|
| 121 |
+
->setValue($conditionAmount);
|
| 122 |
+
|
| 123 |
+
$rule->getActions()->addCondition($actions);
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
// save discount
|
| 127 |
+
$rule->save();
|
| 128 |
+
|
| 129 |
+
return json_encode(array(
|
| 130 |
+
"status" => true
|
| 131 |
+
));
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
return json_encode(array(
|
| 135 |
+
"status" => false,
|
| 136 |
+
"error" => "0003: Invalid Parameters!"
|
| 137 |
+
));
|
| 138 |
+
}
|
| 139 |
+
}
|
app/code/community/Retargeting/Tracker/controllers/IndexController.php
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
class Retargeting_Tracker_IndexController extends Mage_Core_Controller_Front_Action
|
| 11 |
+
{
|
| 12 |
+
public function indexAction() {
|
| 13 |
+
echo '<h1>Have an awesome day! - <a href="http://www.retargeting.biz">Retargeting Team</a></h1>';
|
| 14 |
+
}
|
| 15 |
+
}
|
app/code/community/Retargeting/Tracker/etc/config.xml
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* @category Retargeting
|
| 5 |
+
* @package Retargeting_Tracker
|
| 6 |
+
* @author Retargeting <info@retargeting.biz>
|
| 7 |
+
* @copyright Copyright (c) Retargeting
|
| 8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 9 |
+
*/
|
| 10 |
+
-->
|
| 11 |
+
<config>
|
| 12 |
+
<modules>
|
| 13 |
+
<Retargeting_Tracker>
|
| 14 |
+
<version>1.0.0</version>
|
| 15 |
+
</Retargeting_Tracker>
|
| 16 |
+
</modules>
|
| 17 |
+
<global>
|
| 18 |
+
<blocks>
|
| 19 |
+
<retargeting_tracker><class>Retargeting_Tracker_Block</class></retargeting_tracker>
|
| 20 |
+
<retargeting_tracker_adminhtml><class>Retargeting_Tracker_Block_Adminhtml</class></retargeting_tracker_adminhtml>
|
| 21 |
+
</blocks>
|
| 22 |
+
<models>
|
| 23 |
+
<retargeting_tracker><class>Retargeting_Tracker_Model</class></retargeting_tracker>
|
| 24 |
+
</models>
|
| 25 |
+
<helpers>
|
| 26 |
+
<retargeting_tracker><class>Retargeting_Tracker_Helper</class></retargeting_tracker>
|
| 27 |
+
</helpers>
|
| 28 |
+
<!--
|
| 29 |
+
<resources>
|
| 30 |
+
<retargeting_tracker_setup>
|
| 31 |
+
<setup>
|
| 32 |
+
<module>Retargeting_Tracker</module>
|
| 33 |
+
</setup>
|
| 34 |
+
</retargeting_tracker_setup>
|
| 35 |
+
</resources>
|
| 36 |
+
-->
|
| 37 |
+
<events>
|
| 38 |
+
<customer_login>
|
| 39 |
+
<observers>
|
| 40 |
+
<retargeting_tracker><class>Retargeting_Tracker_Model_Observer</class>
|
| 41 |
+
<method>TrackSetEmail</method>
|
| 42 |
+
</retargeting_tracker>
|
| 43 |
+
</observers>
|
| 44 |
+
</customer_login>
|
| 45 |
+
<checkout_cart_product_add_after>
|
| 46 |
+
<observers>
|
| 47 |
+
<retargeting_tracker><class>Retargeting_Tracker_Model_Observer</class>
|
| 48 |
+
<method>TrackAddToCart</method>
|
| 49 |
+
</retargeting_tracker>
|
| 50 |
+
</observers>
|
| 51 |
+
</checkout_cart_product_add_after>
|
| 52 |
+
<wishlist_add_product>
|
| 53 |
+
<observers>
|
| 54 |
+
<retargeting_tracker><class>Retargeting_Tracker_Model_Observer</class>
|
| 55 |
+
<method>TrackAddToWishlist</method>
|
| 56 |
+
</retargeting_tracker>
|
| 57 |
+
</observers>
|
| 58 |
+
</wishlist_add_product>
|
| 59 |
+
<review_save_after>
|
| 60 |
+
<observers>
|
| 61 |
+
<retargeting_tracker><class>Retargeting_Tracker_Model_Observer</class>
|
| 62 |
+
<method>TrackCommentOnProduct</method>
|
| 63 |
+
</retargeting_tracker>
|
| 64 |
+
</observers>
|
| 65 |
+
</review_save_after>
|
| 66 |
+
<sales_order_save_after>
|
| 67 |
+
<observers>
|
| 68 |
+
<retargeting_tracker><class>Retargeting_Tracker_Model_Observer</class>
|
| 69 |
+
<method>TrackSaveOrder</method>
|
| 70 |
+
</retargeting_tracker>
|
| 71 |
+
</observers>
|
| 72 |
+
</sales_order_save_after>
|
| 73 |
+
</events>
|
| 74 |
+
</global>
|
| 75 |
+
<frontend>
|
| 76 |
+
<routers>
|
| 77 |
+
<retargeting_tracker>
|
| 78 |
+
<use>standard</use>
|
| 79 |
+
<args>
|
| 80 |
+
<module>Retargeting_Tracker</module>
|
| 81 |
+
<frontName>retargetingtracker</frontName>
|
| 82 |
+
</args>
|
| 83 |
+
</retargeting_tracker>
|
| 84 |
+
</routers>
|
| 85 |
+
<layout>
|
| 86 |
+
<updates>
|
| 87 |
+
<retargeting_tracker>
|
| 88 |
+
<file>retargeting_tracker.xml</file>
|
| 89 |
+
</retargeting_tracker>
|
| 90 |
+
</updates>
|
| 91 |
+
</layout>
|
| 92 |
+
</frontend>
|
| 93 |
+
<!--
|
| 94 |
+
<admin>
|
| 95 |
+
<routers>
|
| 96 |
+
<adminhtml>
|
| 97 |
+
<args>
|
| 98 |
+
<modules>
|
| 99 |
+
<Retargeting_Tracker before="Mage_Adminhtml">Retargeting_Tracker_Adminhtml</Retargeting_Tracker>
|
| 100 |
+
</modules>
|
| 101 |
+
</args>
|
| 102 |
+
</adminhtml>
|
| 103 |
+
</routers>
|
| 104 |
+
</admin>
|
| 105 |
+
-->
|
| 106 |
+
<!--
|
| 107 |
+
<crontab>
|
| 108 |
+
<jobs>
|
| 109 |
+
<retargeting_tracker_cron>
|
| 110 |
+
<schedule>
|
| 111 |
+
<cron_expr>0,45 * * * *</cron_expr>
|
| 112 |
+
</schedule>
|
| 113 |
+
<run>
|
| 114 |
+
<model>retargeting_tracker/observer::methodName</model>
|
| 115 |
+
</run>
|
| 116 |
+
</retargeting_tracker_cron>
|
| 117 |
+
</jobs>
|
| 118 |
+
</crontab>
|
| 119 |
+
-->
|
| 120 |
+
<adminhtml>
|
| 121 |
+
<acl>
|
| 122 |
+
<resources>
|
| 123 |
+
<admin>
|
| 124 |
+
<children>
|
| 125 |
+
<system>
|
| 126 |
+
<children>
|
| 127 |
+
<config>
|
| 128 |
+
<children>
|
| 129 |
+
<retargetingtracker_options>
|
| 130 |
+
<title>Store Retargeting Tracker Module Section</title>
|
| 131 |
+
</retargetingtracker_options>
|
| 132 |
+
</children>
|
| 133 |
+
</config>
|
| 134 |
+
</children>
|
| 135 |
+
</system>
|
| 136 |
+
</children>
|
| 137 |
+
</admin>
|
| 138 |
+
</resources>
|
| 139 |
+
</acl>
|
| 140 |
+
</adminhtml>
|
| 141 |
+
</config>
|
app/code/community/Retargeting/Tracker/etc/system.xml
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* @category Retargeting
|
| 5 |
+
* @package Retargeting_Tracker
|
| 6 |
+
* @author Retargeting <info@retargeting.biz>
|
| 7 |
+
* @copyright Copyright (c) Retargeting
|
| 8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 9 |
+
*/
|
| 10 |
+
-->
|
| 11 |
+
<config>
|
| 12 |
+
<tabs>
|
| 13 |
+
<retargetingconfig translate="label" module="retargeting_tracker">
|
| 14 |
+
<label>Retargeting</label>
|
| 15 |
+
<sort_order>99999</sort_order>
|
| 16 |
+
</retargetingconfig>
|
| 17 |
+
</tabs>
|
| 18 |
+
<sections>
|
| 19 |
+
<retargetingtracker_options translate="label" module="retargeting_tracker">
|
| 20 |
+
<label>Retargeting Tracker Options</label>
|
| 21 |
+
<tab>retargetingconfig</tab>
|
| 22 |
+
<frontend_type>text</frontend_type>
|
| 23 |
+
<sort_order>1000</sort_order>
|
| 24 |
+
<show_in_default>1</show_in_default>
|
| 25 |
+
<show_in_website>1</show_in_website>
|
| 26 |
+
<show_in_store>1</show_in_store>
|
| 27 |
+
<groups>
|
| 28 |
+
<domain translate="label">
|
| 29 |
+
<label>Domain</label>
|
| 30 |
+
<frontend_type>text</frontend_type>
|
| 31 |
+
<sort_order>1</sort_order>
|
| 32 |
+
<show_in_default>1</show_in_default>
|
| 33 |
+
<show_in_website>1</show_in_website>
|
| 34 |
+
<show_in_store>1</show_in_store>
|
| 35 |
+
<fields>
|
| 36 |
+
<domain_api_key>
|
| 37 |
+
<label>Domain API Key</label>
|
| 38 |
+
<frontend_type>text</frontend_type>
|
| 39 |
+
<sort_order>1</sort_order>
|
| 40 |
+
<show_in_default>1</show_in_default>
|
| 41 |
+
<show_in_website>1</show_in_website>
|
| 42 |
+
<show_in_store>1</show_in_store>
|
| 43 |
+
</domain_api_key>
|
| 44 |
+
</fields>
|
| 45 |
+
</domain>
|
| 46 |
+
<discounts translate="label">
|
| 47 |
+
<label>Discounts</label>
|
| 48 |
+
<frontend_type>text</frontend_type>
|
| 49 |
+
<sort_order>1</sort_order>
|
| 50 |
+
<show_in_default>1</show_in_default>
|
| 51 |
+
<show_in_website>1</show_in_website>
|
| 52 |
+
<show_in_store>1</show_in_store>
|
| 53 |
+
<fields>
|
| 54 |
+
<discount_api_key>
|
| 55 |
+
<label>Discounts API Key</label>
|
| 56 |
+
<frontend_type>text</frontend_type>
|
| 57 |
+
<sort_order>1</sort_order>
|
| 58 |
+
<show_in_default>1</show_in_default>
|
| 59 |
+
<show_in_website>1</show_in_website>
|
| 60 |
+
<show_in_store>1</show_in_store>
|
| 61 |
+
</discount_api_key>
|
| 62 |
+
</fields>
|
| 63 |
+
</discounts>
|
| 64 |
+
<more translate="label">
|
| 65 |
+
<label>More</label>
|
| 66 |
+
<frontend_type>text</frontend_type>
|
| 67 |
+
<sort_order>2</sort_order>
|
| 68 |
+
<show_in_default>1</show_in_default>
|
| 69 |
+
<show_in_website>1</show_in_website>
|
| 70 |
+
<show_in_store>1</show_in_store>
|
| 71 |
+
<fields>
|
| 72 |
+
<help_pages>
|
| 73 |
+
<label>Help Pages</label>
|
| 74 |
+
<frontend_type>multiselect</frontend_type>
|
| 75 |
+
<source_model>retargeting_tracker/helppages</source_model>
|
| 76 |
+
<sort_order>1</sort_order>
|
| 77 |
+
<show_in_default>1</show_in_default>
|
| 78 |
+
<show_in_website>1</show_in_website>
|
| 79 |
+
<show_in_store>1</show_in_store>
|
| 80 |
+
</help_pages>
|
| 81 |
+
</fields>
|
| 82 |
+
</more>
|
| 83 |
+
</groups>
|
| 84 |
+
</retargetingtracker_options>
|
| 85 |
+
</sections>
|
| 86 |
+
</config>
|
app/code/community/Retargeting/Tracker/sql/retargeting_tracker_setup/mysql4-install-1.0.0.php
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
$installer = $this;
|
| 11 |
+
|
| 12 |
+
$installer->startSetup();
|
| 13 |
+
|
| 14 |
+
$tableName = $installer->getTable('retargeting_tracker');
|
| 15 |
+
|
| 16 |
+
$sql=<<<SQLTEXT
|
| 17 |
+
CREATE TABLE `{$tableName}` (
|
| 18 |
+
`id` INT NOT NULL AUTO_INCREMENT ,
|
| 19 |
+
`name` VARCHAR( 64 ) NOT NULL ,
|
| 20 |
+
`created_at` DATETIME NOT NULL ,
|
| 21 |
+
PRIMARY KEY ( `id` )
|
| 22 |
+
) ENGINE = InnoDB;
|
| 23 |
+
SQLTEXT;
|
| 24 |
+
|
| 25 |
+
$installer->run($sql);
|
| 26 |
+
|
| 27 |
+
$installer->endSetup();
|
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,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
console.log('Retargeting: code embeded!');
|
| 12 |
+
(function(){
|
| 13 |
+
var ra = document.createElement("script"); ra.type ="text/javascript"; ra.async = true; ra.src = ("https:" ==
|
| 14 |
+
document.location.protocol ? "https://" : "http://") + "retargeting-data.eu/" +
|
| 15 |
+
document.location.hostname.replace("www.","") + "/ra.js"; var s =
|
| 16 |
+
document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ra,s);})();
|
| 17 |
+
</script>
|
app/design/frontend/base/default/template/retargeting_tracker/triggers.phtml
ADDED
|
@@ -0,0 +1,985 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 if ( Mage::app()->getFrontController()->getRequest()->getControllerName() == "product" && !is_null(Mage::registry('product')) ) : ?>
|
| 16 |
+
<script>
|
| 17 |
+
// Retargeting JS helpers
|
| 18 |
+
function _ra_helper_addLoadEvent(func) {
|
| 19 |
+
var oldonload = window.onload;
|
| 20 |
+
if (typeof window.onload != 'function') {
|
| 21 |
+
window.onload = func;
|
| 22 |
+
} else {
|
| 23 |
+
window.onload = function() {
|
| 24 |
+
if (oldonload) {
|
| 25 |
+
oldonload();
|
| 26 |
+
}
|
| 27 |
+
func();
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
}
|
| 31 |
+
</script>
|
| 32 |
+
<?php endif ?>
|
| 33 |
+
|
| 34 |
+
<script>
|
| 35 |
+
<?php
|
| 36 |
+
/*
|
| 37 |
+
----------------------- Trigger setEmail -----------------------
|
| 38 |
+
*/
|
| 39 |
+
?>
|
| 40 |
+
<?php if ( $info = Mage::getSingleton('core/session')->getTriggerSetEmail() ) : ?>
|
| 41 |
+
|
| 42 |
+
// Trigger setEmail
|
| 43 |
+
|
| 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 |
+
|
| 53 |
+
if (_ra.ready !== undefined) {
|
| 54 |
+
if(typeof _ra.setEmail !== "undefined") _ra.setEmail(_ra.setEmailInfo);
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
<?php Mage::getSingleton('core/session')->unsTriggerSetEmail(); ?>
|
| 58 |
+
<?php endif ?>
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
<?php
|
| 63 |
+
/*
|
| 64 |
+
----------------------- Trigger sendCategory -----------------------
|
| 65 |
+
*/
|
| 66 |
+
?>
|
| 67 |
+
<?php if ( Mage::app()->getFrontController()->getRequest()->getControllerName() == "category" ) : ?>
|
| 68 |
+
|
| 69 |
+
// Trigger sendCategory
|
| 70 |
+
|
| 71 |
+
<?php $_category = Mage::registry('current_category'); ?>
|
| 72 |
+
<?php
|
| 73 |
+
$_categoryParent = "false";
|
| 74 |
+
$_categoryBreadcrumb = "[]";
|
| 75 |
+
if ( $_category->getLevel() > 2 ) {
|
| 76 |
+
$_categoryParent = '"'.$_category->getParentId().'"';
|
| 77 |
+
$_categoryBreadcrumb = array();
|
| 78 |
+
$breadcrumbCategory = $_category;
|
| 79 |
+
while ( $breadcrumbCategory->getLevel() > 2 ) {
|
| 80 |
+
$breadcrumbCategory = Mage::getModel('catalog/category')->load($breadcrumbCategory->getParentId());
|
| 81 |
+
|
| 82 |
+
$_categoryBreadcrumb[] = '{
|
| 83 |
+
"id": "'.$breadcrumbCategory->getId().'",
|
| 84 |
+
"name": "'.htmlspecialchars($breadcrumbCategory->getName()).'",
|
| 85 |
+
"parent": '.( $breadcrumbCategory->getLevel() > 2 ? '"'.$breadcrumbCategory->getParentId().'"' : 'false' ).'
|
| 86 |
+
}';
|
| 87 |
+
}
|
| 88 |
+
$_categoryBreadcrumb = '['.implode(', ', $_categoryBreadcrumb).']';
|
| 89 |
+
}
|
| 90 |
+
?>
|
| 91 |
+
|
| 92 |
+
var _ra = _ra || {};
|
| 93 |
+
_ra.sendCategoryInfo = {
|
| 94 |
+
"id": "<?php echo $_category->getId(); ?>",
|
| 95 |
+
"name": "<?php echo htmlspecialchars($_category->getName()); ?>",
|
| 96 |
+
"parent": <?php echo $_categoryParent; ?>,
|
| 97 |
+
"category_breadcrumb": <?php echo $_categoryBreadcrumb; ?>
|
| 98 |
+
};
|
| 99 |
+
|
| 100 |
+
if (_ra.ready !== undefined) {
|
| 101 |
+
if(typeof _ra.sendCategory !== "undefined") _ra.sendCategory(_ra.sendCategoryInfo);
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
<?php endif ?>
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
<?php
|
| 109 |
+
/*
|
| 110 |
+
----------------------- Trigger sendBrand -----------------------
|
| 111 |
+
magento doesn't have core support for brands..
|
| 112 |
+
*/
|
| 113 |
+
?>
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
<?php
|
| 118 |
+
/*
|
| 119 |
+
----------------------- Trigger sendProduct -----------------------
|
| 120 |
+
*/
|
| 121 |
+
?>
|
| 122 |
+
<?php if ( Mage::app()->getFrontController()->getRequest()->getControllerName() == "product" && !is_null(Mage::registry('product')) ) : ?>
|
| 123 |
+
|
| 124 |
+
// Trigger sendProduct
|
| 125 |
+
|
| 126 |
+
<?php $_product = Mage::registry('current_product'); ?>
|
| 127 |
+
<?php
|
| 128 |
+
$_productUrl = Mage::helper('core/url')->getCurrentUrl();
|
| 129 |
+
|
| 130 |
+
$_category = false;
|
| 131 |
+
if ( Mage::registry('current_category') ) {
|
| 132 |
+
$_category = Mage::registry('current_category');
|
| 133 |
+
} else {
|
| 134 |
+
$_productCategoryIds = $_product->getCategoryIds();
|
| 135 |
+
if ( count($_productCategoryIds) ) {
|
| 136 |
+
$firstCategoryId = $_productCategoryIds[0];
|
| 137 |
+
$_category = Mage::getModel('catalog/category')->load($firstCategoryId);
|
| 138 |
+
}
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
$_categoryParent = "false";
|
| 142 |
+
$_categoryBreadcrumb = "[]";
|
| 143 |
+
|
| 144 |
+
if($_category) {
|
| 145 |
+
if ( $_category->getLevel() > 2 ) {
|
| 146 |
+
$_categoryParent = '"'.$_category->getParentId().'"';
|
| 147 |
+
$_categoryBreadcrumb = array();
|
| 148 |
+
$breadcrumbCategory = $_category;
|
| 149 |
+
while ( $breadcrumbCategory->getLevel() > 2 ) {
|
| 150 |
+
$breadcrumbCategory = Mage::getModel('catalog/category')->load($breadcrumbCategory->getParentId());
|
| 151 |
+
|
| 152 |
+
$_categoryBreadcrumb[] = '{
|
| 153 |
+
"id": "'.$breadcrumbCategory->getId().'",
|
| 154 |
+
"name": "'.htmlspecialchars($breadcrumbCategory->getName()).'",
|
| 155 |
+
"parent": '.( $breadcrumbCategory->getLevel() > 2 ? '"'.$breadcrumbCategory->getParentId().'"' : 'false' ).'
|
| 156 |
+
}';
|
| 157 |
+
}
|
| 158 |
+
$_categoryBreadcrumb = '['.implode(', ', $_categoryBreadcrumb).']';
|
| 159 |
+
}
|
| 160 |
+
$_category = '{"id": "'.$_category->getId().'", "name": "'.htmlspecialchars($_category->getName()).'", "parent": '.$_categoryParent.'}';
|
| 161 |
+
} else {
|
| 162 |
+
$_category = '{"id": "-1", "name": "no category", "parent": false}';
|
| 163 |
+
}
|
| 164 |
+
?>
|
| 165 |
+
|
| 166 |
+
var _ra = _ra || {};
|
| 167 |
+
_ra.sendProductInfo = {
|
| 168 |
+
"id": "<?php echo $_product->getId(); ?>",
|
| 169 |
+
"name": "<?php echo htmlspecialchars($_product->getName()); ?>",
|
| 170 |
+
"url": "<?php echo htmlspecialchars($_productUrl); ?>",
|
| 171 |
+
"img": "<?php echo htmlspecialchars(Mage::helper('catalog/image')->init($_product, 'thumbnail')); ?>",
|
| 172 |
+
"price": <?php echo Mage::helper('tax')->getPrice($_product, $_product->getPrice()); ?>,
|
| 173 |
+
"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 ); ?>,
|
| 174 |
+
"stock": <?php echo $_product->getIsInStock() ?>,
|
| 175 |
+
"brand": false,
|
| 176 |
+
"category": <?php echo $_category; ?>,
|
| 177 |
+
"category_breadcrumb": <?php echo $_categoryBreadcrumb; ?>
|
| 178 |
+
};
|
| 179 |
+
|
| 180 |
+
if (_ra.ready !== undefined) {
|
| 181 |
+
if(typeof _ra.sendProduct !== "undefined") _ra.sendProduct(_ra.sendProductInfo);
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
<?php endif ?>
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
<?php
|
| 189 |
+
/*
|
| 190 |
+
----------------------- Trigger addToCart -----------------------
|
| 191 |
+
*/
|
| 192 |
+
?>
|
| 193 |
+
<?php if ( $info = Mage::getSingleton('core/session')->getTriggerAddToCart() ) : ?>
|
| 194 |
+
|
| 195 |
+
// Trigger addToCart
|
| 196 |
+
|
| 197 |
+
<?php $referral = Mage::getSingleton('core/session')->getReferralController(); echo "/*".$referral."*/"; ?>
|
| 198 |
+
<?php if ( $referral != "product" ) : ?>
|
| 199 |
+
|
| 200 |
+
// Trigger sendProduct before addToCart
|
| 201 |
+
|
| 202 |
+
<?php
|
| 203 |
+
$_product = Mage::getModel('catalog/product')->load($info['product_id']);
|
| 204 |
+
$_productUrl = $_product->getProductUrl();
|
| 205 |
+
$_category = false;
|
| 206 |
+
|
| 207 |
+
$_productCategoryIds = $_product->getCategoryIds();
|
| 208 |
+
if ( count($_productCategoryIds) ) {
|
| 209 |
+
$firstCategoryId = $_productCategoryIds[0];
|
| 210 |
+
$_category = Mage::getModel('catalog/category')->load($firstCategoryId);
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
$_categoryParent = "false";
|
| 214 |
+
$_categoryBreadcrumb = "[]";
|
| 215 |
+
|
| 216 |
+
if($_category) {
|
| 217 |
+
if ( $_category->getLevel() > 2 ) {
|
| 218 |
+
$_categoryParent = '"'.$_category->getParentId().'"';
|
| 219 |
+
$_categoryBreadcrumb = array();
|
| 220 |
+
$breadcrumbCategory = $_category;
|
| 221 |
+
while ( $breadcrumbCategory->getLevel() > 2 ) {
|
| 222 |
+
$breadcrumbCategory = Mage::getModel('catalog/category')->load($breadcrumbCategory->getParentId());
|
| 223 |
+
|
| 224 |
+
$_categoryBreadcrumb[] = '{
|
| 225 |
+
"id": "'.$breadcrumbCategory->getId().'",
|
| 226 |
+
"name": "'.htmlspecialchars($breadcrumbCategory->getName()).'",
|
| 227 |
+
"parent": '.( $breadcrumbCategory->getLevel() > 2 ? '"'.$breadcrumbCategory->getParentId().'"' : 'false' ).'
|
| 228 |
+
}';
|
| 229 |
+
}
|
| 230 |
+
$_categoryBreadcrumb = '['.implode(', ', $_categoryBreadcrumb).']';
|
| 231 |
+
}
|
| 232 |
+
$_category = '{"id": "'.$_category->getId().'", "name": "'.htmlspecialchars($_category->getName()).'", "parent": '.$_categoryParent.'}';
|
| 233 |
+
} else {
|
| 234 |
+
$_category = '{"id": "-1", "name": "no category", "parent": false}';
|
| 235 |
+
}
|
| 236 |
+
?>
|
| 237 |
+
|
| 238 |
+
var _ra = _ra || {};
|
| 239 |
+
_ra.sendProductInfo = {
|
| 240 |
+
"id": "<?php echo $_product->getId(); ?>",
|
| 241 |
+
"name": "<?php echo htmlspecialchars($_product->getName()); ?>",
|
| 242 |
+
"url": "<?php echo htmlspecialchars($_productUrl); ?>",
|
| 243 |
+
"img": "<?php echo htmlspecialchars(Mage::helper('catalog/image')->init($_product, 'thumbnail')); ?>",
|
| 244 |
+
"price": <?php echo Mage::helper('tax')->getPrice($_product, $_product->getPrice()); ?>,
|
| 245 |
+
"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 ); ?>,
|
| 246 |
+
"stock": <?php echo $_product->getIsInStock() ?>,
|
| 247 |
+
"brand": false,
|
| 248 |
+
"category": <?php echo $_category; ?>,
|
| 249 |
+
"category_breadcrumb": <?php echo $_categoryBreadcrumb; ?>,
|
| 250 |
+
"callback_function": function() {
|
| 251 |
+
_ra.addToCartInfo = {
|
| 252 |
+
"product_id": "<?php echo $info['product_id']; ?>",
|
| 253 |
+
"variation": <?php echo $info['variation']; ?>
|
| 254 |
+
};
|
| 255 |
+
if(typeof _ra.addToCart !== "undefined") _ra.addToCart(_ra.addToCartInfo.product_id, _ra.addToCartInfo.variation);
|
| 256 |
+
}
|
| 257 |
+
};
|
| 258 |
+
|
| 259 |
+
if (_ra.ready !== undefined) {
|
| 260 |
+
if(typeof _ra.sendProduct !== "undefined") _ra.sendProduct(_ra.sendProductInfo);
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
<?php else : ?>
|
| 264 |
+
|
| 265 |
+
var _ra = _ra || {};
|
| 266 |
+
_ra.addToCartInfo = {
|
| 267 |
+
"product_id": "<?php echo $info['product_id']; ?>",
|
| 268 |
+
"variation": <?php echo $info['variation']; ?>
|
| 269 |
+
};
|
| 270 |
+
|
| 271 |
+
if (_ra.ready !== undefined) {
|
| 272 |
+
if(typeof _ra.addToCart !== "undefined") _ra.addToCart(_ra.addToCartInfo.product_id, _ra.addToCartInfo.variation);
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
<?php endif ?>
|
| 276 |
+
|
| 277 |
+
<?php Mage::getSingleton('core/session')->unsTriggerAddToCart(); ?>
|
| 278 |
+
<?php endif ?>
|
| 279 |
+
|
| 280 |
+
|
| 281 |
+
|
| 282 |
+
<?php
|
| 283 |
+
/*
|
| 284 |
+
----------------------- Trigger setVariation -----------------------
|
| 285 |
+
*/
|
| 286 |
+
?>
|
| 287 |
+
<?php if ( Mage::app()->getFrontController()->getRequest()->getControllerName() == "product" && !is_null(Mage::registry('product')) ) : ?>
|
| 288 |
+
|
| 289 |
+
// Trigger setVariation
|
| 290 |
+
|
| 291 |
+
<?php $_product = Mage::registry('current_product'); ?>
|
| 292 |
+
|
| 293 |
+
/*<?php print_r($_product->isConfigurable()); ?>*/
|
| 294 |
+
<?php if ( !$_product->isConfigurable() ) : ?>
|
| 295 |
+
<?php /*is not configurable*/ ?>
|
| 296 |
+
<?php if ( $_product->getTypeInstance(true)->hasOptions($_product) ) : ?>
|
| 297 |
+
|
| 298 |
+
function _ra_triggerSetVariation() {
|
| 299 |
+
var _ra_variation = _ra_grabVariation();
|
| 300 |
+
if(typeof _ra.setVariation !== "undefined") _ra.setVariation("<?php echo $_product->getId(); ?>", _ra_variation);
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
|
| 304 |
+
_ra_optElfunc = [];
|
| 305 |
+
|
| 306 |
+
|
| 307 |
+
|
| 308 |
+
function _ra_grabVariation() {
|
| 309 |
+
var _ra_vo = {};
|
| 310 |
+
var _ra_voCode = [];
|
| 311 |
+
var _ra_voDetails = {};
|
| 312 |
+
<?php foreach ( $_product->getOptions() as $o ) : ?>
|
| 313 |
+
<?php $optionType = $o->getType(); ?>
|
| 314 |
+
<?php $optionId = $o->getId(); ?>
|
| 315 |
+
<?php $optionTitle = $o->getTitle(); ?>
|
| 316 |
+
|
| 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 |
+
|
| 372 |
+
<?php if ( $optionType == "multiple" ) : ?>
|
| 373 |
+
if ( document.querySelector("select.multiselect.product-custom-option[name='options[<?php echo $optionId; ?>][]']") !== null ) {
|
| 374 |
+
var _ra_optionValue = [];
|
| 375 |
+
var _ra_arr = document.querySelector("select.multiselect.product-custom-option[name='options[<?php echo $optionId; ?>][]']").options;
|
| 376 |
+
for ( var index = 0; index < _ra_arr.length; index ++ ) {
|
| 377 |
+
if ( _ra_arr[index].selected ) _ra_optionValue.push(_ra_arr[index].text);
|
| 378 |
+
}
|
| 379 |
+
_ra_voCode.push(_ra_optionValue.join('_'));
|
| 380 |
+
}
|
| 381 |
+
<?php endif ?>
|
| 382 |
+
|
| 383 |
+
<?php if ( $optionType == "radio" ) : ?>
|
| 384 |
+
if ( document.querySelectorAll("input[type='radio'].product-custom-option[name='options[<?php echo $optionId; ?>]']").length > 0 ) {
|
| 385 |
+
var _ra_optionValue = [];
|
| 386 |
+
var _ra_arr = document.querySelectorAll("input[type='radio'].product-custom-option[name='options[<?php echo $optionId; ?>]']");
|
| 387 |
+
for( var index = 0; index < _ra_arr.length; index ++ ) {
|
| 388 |
+
if(_ra_arr[index].checked) {
|
| 389 |
+
_ra_optionValue.push(document.querySelector("label[for='"+_ra_arr[index].getAttribute('id')+"']").innerText);
|
| 390 |
+
}
|
| 391 |
+
}
|
| 392 |
+
_ra_voCode.push(_ra_optionValue.join(', '));
|
| 393 |
+
}
|
| 394 |
+
<?php endif ?>
|
| 395 |
+
|
| 396 |
+
<?php if ( $optionType == "time" ) : ?>
|
| 397 |
+
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 ) {
|
| 398 |
+
var _ra_optionValue = [];
|
| 399 |
+
_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);
|
| 400 |
+
_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);
|
| 401 |
+
_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);
|
| 402 |
+
_ra_voCode.push(_ra_optionValue.join('/'));
|
| 403 |
+
}
|
| 404 |
+
<?php endif ?>
|
| 405 |
+
|
| 406 |
+
<?php if ( $optionType == "file" ) : ?>
|
| 407 |
+
if ( document.querySelector("input[type='file'].product-custom-option[name='options_<?php echo $optionId; ?>_file']") !== null ) {
|
| 408 |
+
_ra_voCode.push(document.querySelector("input[type='file'].product-custom-option[name='options_<?php echo $optionId; ?>_file']").value.split(/(\\|\/)/g).pop());
|
| 409 |
+
}
|
| 410 |
+
<?php endif ?>
|
| 411 |
+
|
| 412 |
+
_ra_voDetails[_ra_voCode[_ra_voCode.length - 1].replace(RegExp("[- ]", 'g'), '')] = {
|
| 413 |
+
"category_name": "<?php echo $optionTitle; ?>",
|
| 414 |
+
"category": "<?php echo $optionTitle; ?>",
|
| 415 |
+
"value": _ra_voCode[_ra_voCode.length - 1]
|
| 416 |
+
};
|
| 417 |
+
_ra_voCode[_ra_voCode.length - 1] = _ra_voCode[_ra_voCode.length - 1].replace(RegExp("[- ]", 'g'), '');
|
| 418 |
+
|
| 419 |
+
<?php endforeach ?>
|
| 420 |
+
|
| 421 |
+
var _ra_vo = {
|
| 422 |
+
"code": _ra_voCode.join('-'),
|
| 423 |
+
"details": _ra_voDetails
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
return _ra_vo;
|
| 427 |
+
}
|
| 428 |
+
|
| 429 |
+
|
| 430 |
+
|
| 431 |
+
|
| 432 |
+
_ra_helper_addLoadEvent(function() {
|
| 433 |
+
|
| 434 |
+
<?php foreach ( $_product->getOptions() as $o ) : ?>
|
| 435 |
+
<?php $optionType = $o->getType(); ?>
|
| 436 |
+
<?php $optionId = $o->getId(); ?>
|
| 437 |
+
|
| 438 |
+
<?php if ( $optionType == "area" ) : ?>
|
| 439 |
+
if ( document.querySelector(".product-custom-option[name='options[<?php echo $optionId; ?>]']") !== null ) {
|
| 440 |
+
_ra_optElfunc[<?php echo $optionId; ?>] = document.querySelector(".product-custom-option[name='options[<?php echo $optionId; ?>]']").onchange;
|
| 441 |
+
document.querySelector(".product-custom-option[name='options[<?php echo $optionId; ?>]']").onchange = function() {
|
| 442 |
+
if ( _ra_optElfunc[<?php echo $optionId; ?>] !== null ) _ra_optElfunc[<?php echo $optionId; ?>]();
|
| 443 |
+
_ra_triggerSetVariation();
|
| 444 |
+
}
|
| 445 |
+
}
|
| 446 |
+
<?php endif ?>
|
| 447 |
+
|
| 448 |
+
<?php if ( $optionType == "field" ) : ?>
|
| 449 |
+
if ( document.querySelector(".product-custom-option[name='options[<?php echo $optionId; ?>]']") !== null ) {
|
| 450 |
+
_ra_optElfunc[<?php echo $optionId; ?>] = document.querySelector(".product-custom-option[name='options[<?php echo $optionId; ?>]']").onchange;
|
| 451 |
+
document.querySelector(".product-custom-option[name='options[<?php echo $optionId; ?>]']").onchange = function() {
|
| 452 |
+
if ( _ra_optElfunc[<?php echo $optionId; ?>] !== null ) _ra_optElfunc[<?php echo $optionId; ?>]();
|
| 453 |
+
_ra_triggerSetVariation();
|
| 454 |
+
}
|
| 455 |
+
}
|
| 456 |
+
<?php endif ?>
|
| 457 |
+
|
| 458 |
+
<?php if ( $optionType == "checkbox" ) : ?>
|
| 459 |
+
if ( document.querySelectorAll("input[type='checkbox'].product-custom-option[name='options[<?php echo $optionId; ?>][]']").length > 0 ) {
|
| 460 |
+
_ra_optElfunc[<?php echo $optionId; ?>] = [];
|
| 461 |
+
for ( var index = 0; index < document.querySelectorAll("input[type='checkbox'].product-custom-option[name='options[<?php echo $optionId; ?>][]']").length; index ++ ) {
|
| 462 |
+
_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;
|
| 463 |
+
document.querySelectorAll("input[type='checkbox'].product-custom-option[name='options[<?php echo $optionId; ?>][]']")[index].onclick = function() {
|
| 464 |
+
if ( _ra_optElfunc[this] !== null ) _ra_optElfunc[this]();
|
| 465 |
+
_ra_triggerSetVariation();
|
| 466 |
+
}
|
| 467 |
+
}
|
| 468 |
+
}
|
| 469 |
+
<?php endif ?>
|
| 470 |
+
|
| 471 |
+
<?php if ( $optionType == "date" ) : ?>
|
| 472 |
+
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 ) {
|
| 473 |
+
_ra_optElfunc[<?php echo $optionId; ?>] = [];
|
| 474 |
+
_ra_optElfunc[<?php echo $optionId; ?>][0] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']").onchange;
|
| 475 |
+
_ra_optElfunc[<?php echo $optionId; ?>][1] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']").onchange;
|
| 476 |
+
_ra_optElfunc[<?php echo $optionId; ?>][2] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']").onchange;
|
| 477 |
+
document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']").onchange = function() {
|
| 478 |
+
if ( _ra_optElfunc[<?php echo $optionId; ?>][0] !== null ) _ra_optElfunc[<?php echo $optionId; ?>][0]();
|
| 479 |
+
_ra_triggerSetVariation();
|
| 480 |
+
}
|
| 481 |
+
document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']").onchange = function() {
|
| 482 |
+
if ( _ra_optElfunc[<?php echo $optionId; ?>][1] !== null ) _ra_optElfunc[<?php echo $optionId; ?>][1]();
|
| 483 |
+
_ra_triggerSetVariation();
|
| 484 |
+
}
|
| 485 |
+
document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']").onchange = function() {
|
| 486 |
+
if ( _ra_optElfunc[<?php echo $optionId; ?>][2] !== null ) _ra_optElfunc[<?php echo $optionId; ?>][2]();
|
| 487 |
+
_ra_triggerSetVariation();
|
| 488 |
+
}
|
| 489 |
+
}
|
| 490 |
+
<?php endif ?>
|
| 491 |
+
|
| 492 |
+
<?php if ( $optionType == "date_time" ) : ?>
|
| 493 |
+
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 ) {
|
| 494 |
+
_ra_optElfunc[<?php echo $optionId; ?>] = [];
|
| 495 |
+
_ra_optElfunc[<?php echo $optionId; ?>][0] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']").onchange;
|
| 496 |
+
_ra_optElfunc[<?php echo $optionId; ?>][1] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']").onchange;
|
| 497 |
+
_ra_optElfunc[<?php echo $optionId; ?>][2] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']").onchange;
|
| 498 |
+
_ra_optElfunc[<?php echo $optionId; ?>][3] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']").onchange;
|
| 499 |
+
_ra_optElfunc[<?php echo $optionId; ?>][4] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']").onchange;
|
| 500 |
+
_ra_optElfunc[<?php echo $optionId; ?>][5] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']").onchange;
|
| 501 |
+
document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][month]']").onchange = function() {
|
| 502 |
+
if ( _ra_optElfunc[<?php echo $optionId; ?>][0] !== null ) _ra_optElfunc[<?php echo $optionId; ?>][0]();
|
| 503 |
+
_ra_triggerSetVariation();
|
| 504 |
+
}
|
| 505 |
+
document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day]']").onchange = function() {
|
| 506 |
+
if ( _ra_optElfunc[<?php echo $optionId; ?>][1] !== null ) _ra_optElfunc[<?php echo $optionId; ?>][1]();
|
| 507 |
+
_ra_triggerSetVariation();
|
| 508 |
+
}
|
| 509 |
+
document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][year]']").onchange = function() {
|
| 510 |
+
if ( _ra_optElfunc[<?php echo $optionId; ?>][2] !== null ) _ra_optElfunc[<?php echo $optionId; ?>][2]();
|
| 511 |
+
_ra_triggerSetVariation();
|
| 512 |
+
}
|
| 513 |
+
document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']").onchange = function() {
|
| 514 |
+
if ( _ra_optElfunc[<?php echo $optionId; ?>][3] !== null ) _ra_optElfunc[<?php echo $optionId; ?>][3]();
|
| 515 |
+
_ra_triggerSetVariation();
|
| 516 |
+
}
|
| 517 |
+
document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']").onchange = function() {
|
| 518 |
+
if ( _ra_optElfunc[<?php echo $optionId; ?>][4] !== null ) _ra_optElfunc[<?php echo $optionId; ?>][4]();
|
| 519 |
+
_ra_triggerSetVariation();
|
| 520 |
+
}
|
| 521 |
+
document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']").onchange = function() {
|
| 522 |
+
if ( _ra_optElfunc[<?php echo $optionId; ?>][5] !== null ) _ra_optElfunc[<?php echo $optionId; ?>][5]();
|
| 523 |
+
_ra_triggerSetVariation();
|
| 524 |
+
}
|
| 525 |
+
}
|
| 526 |
+
<?php endif ?>
|
| 527 |
+
|
| 528 |
+
<?php if ( $optionType == "drop_down" ) : ?>
|
| 529 |
+
if ( document.querySelector("select.product-custom-option[name='options[<?php echo $optionId; ?>]']") !== null ) {
|
| 530 |
+
_ra_optElfunc[<?php echo $optionId; ?>] = document.querySelector("select.product-custom-option[name='options[<?php echo $optionId; ?>]']").onchange;
|
| 531 |
+
document.querySelector("select.product-custom-option[name='options[<?php echo $optionId; ?>]']").onchange = function() {
|
| 532 |
+
if ( _ra_optElfunc[<?php echo $optionId; ?>] !== null ) _ra_optElfunc[<?php echo $optionId; ?>]();
|
| 533 |
+
_ra_triggerSetVariation();
|
| 534 |
+
}
|
| 535 |
+
}
|
| 536 |
+
<?php endif ?>
|
| 537 |
+
|
| 538 |
+
<?php if ( $optionType == "multiple" ) : ?>
|
| 539 |
+
if ( document.querySelector("select.multiselect.product-custom-option[name='options[<?php echo $optionId; ?>][]']") !== null ) {
|
| 540 |
+
_ra_optElfunc[<?php echo $optionId; ?>] = document.querySelector("select.multiselect.product-custom-option[name='options[<?php echo $optionId; ?>][]']").onchange;
|
| 541 |
+
document.querySelector("select.multiselect.product-custom-option[name='options[<?php echo $optionId; ?>][]']").onchange = function() {
|
| 542 |
+
if ( _ra_optElfunc[<?php echo $optionId; ?>] !== null ) _ra_optElfunc[<?php echo $optionId; ?>]();
|
| 543 |
+
_ra_triggerSetVariation();
|
| 544 |
+
}
|
| 545 |
+
}
|
| 546 |
+
<?php endif ?>
|
| 547 |
+
|
| 548 |
+
<?php if ( $optionType == "radio" ) : ?>
|
| 549 |
+
if ( document.querySelectorAll("input[type='radio'].product-custom-option[name='options[<?php echo $optionId; ?>]']").length > 0 ) {
|
| 550 |
+
_ra_optElfunc[<?php echo $optionId; ?>] = [];
|
| 551 |
+
for ( var index = 0; index < document.querySelectorAll("input[type='radio'].product-custom-option[name='options[<?php echo $optionId; ?>]']").length; index ++ ) {
|
| 552 |
+
_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;
|
| 553 |
+
document.querySelectorAll("input[type='radio'].product-custom-option[name='options[<?php echo $optionId; ?>]']")[index].onclick = function() {
|
| 554 |
+
if ( _ra_optElfunc[this] !== null ) _ra_optElfunc[this]();
|
| 555 |
+
_ra_triggerSetVariation();
|
| 556 |
+
}
|
| 557 |
+
}
|
| 558 |
+
}
|
| 559 |
+
<?php endif ?>
|
| 560 |
+
|
| 561 |
+
<?php if ( $optionType == "time" ) : ?>
|
| 562 |
+
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 ) {
|
| 563 |
+
_ra_optElfunc[<?php echo $optionId; ?>] = [];
|
| 564 |
+
_ra_optElfunc[<?php echo $optionId; ?>][0] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']").onchange;
|
| 565 |
+
_ra_optElfunc[<?php echo $optionId; ?>][1] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']").onchange;
|
| 566 |
+
_ra_optElfunc[<?php echo $optionId; ?>][2] = document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']").onchange;
|
| 567 |
+
document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][hour]']").onchange = function() {
|
| 568 |
+
if ( _ra_optElfunc[<?php echo $optionId; ?>][0] !== null ) _ra_optElfunc[<?php echo $optionId; ?>][0]();
|
| 569 |
+
_ra_triggerSetVariation();
|
| 570 |
+
}
|
| 571 |
+
document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][minute]']").onchange = function() {
|
| 572 |
+
if ( _ra_optElfunc[<?php echo $optionId; ?>][1] !== null ) _ra_optElfunc[<?php echo $optionId; ?>][1]();
|
| 573 |
+
_ra_triggerSetVariation();
|
| 574 |
+
}
|
| 575 |
+
document.querySelector(".datetime-picker.product-custom-option[name='options[<?php echo $optionId; ?>][day_part]']").onchange = function() {
|
| 576 |
+
if ( _ra_optElfunc[<?php echo $optionId; ?>][2] !== null ) _ra_optElfunc[<?php echo $optionId; ?>][2]();
|
| 577 |
+
_ra_triggerSetVariation();
|
| 578 |
+
}
|
| 579 |
+
}
|
| 580 |
+
<?php endif ?>
|
| 581 |
+
|
| 582 |
+
<?php if ( $optionType == "file" ) : ?>
|
| 583 |
+
if ( document.querySelector("input[type='file'].product-custom-option[name='options_<?php echo $optionId; ?>_file']") !== null ) {
|
| 584 |
+
_ra_optElfunc[<?php echo $optionId; ?>] = document.querySelector("input[type='file'].product-custom-option[name='options_<?php echo $optionId; ?>_file']").onchange;
|
| 585 |
+
document.querySelector("input[type='file'].product-custom-option[name='options_<?php echo $optionId; ?>_file']").onchange = function() {
|
| 586 |
+
if ( _ra_optElfunc[<?php echo $optionId; ?>] !== null ) _ra_optElfunc[<?php echo $optionId; ?>]();
|
| 587 |
+
_ra_triggerSetVariation();
|
| 588 |
+
}
|
| 589 |
+
}
|
| 590 |
+
<?php endif ?>
|
| 591 |
+
|
| 592 |
+
<?php endforeach ?>
|
| 593 |
+
});
|
| 594 |
+
<?php endif ?>
|
| 595 |
+
|
| 596 |
+
<?php /*is not configurable*/ ?>
|
| 597 |
+
<?php else : ?>
|
| 598 |
+
<?php /*is configurable*/ ?>
|
| 599 |
+
/*configurable product..*/
|
| 600 |
+
<?php $_productAttributeOptions = $_product->getTypeInstance(true)->getConfigurableAttributesAsArray($_product); ?>
|
| 601 |
+
<?php if ( count( $_productAttributeOptions ) > 0 ) : ?>
|
| 602 |
+
|
| 603 |
+
function _ra_triggerSetVariation() {
|
| 604 |
+
var _ra_variation = _ra_grabVariation();
|
| 605 |
+
if(typeof _ra.setVariation !== "undefined") _ra.setVariation("<?php echo $_product->getId(); ?>", _ra_variation);
|
| 606 |
+
}
|
| 607 |
+
|
| 608 |
+
_ra_optElfunc = [];
|
| 609 |
+
|
| 610 |
+
function _ra_grabVariation() {
|
| 611 |
+
var _ra_vo = {};
|
| 612 |
+
var _ra_voCode = [];
|
| 613 |
+
var _ra_voDetails = {};
|
| 614 |
+
|
| 615 |
+
<?php foreach ($_productAttributeOptions as $_productAttribute) : ?>
|
| 616 |
+
<?php $attributeId = $_productAttribute["attribute_id"]; ?>
|
| 617 |
+
<?php $attributeTitle = $_productAttribute["label"]; ?>
|
| 618 |
+
if ( document.getElementById("attribute<?php echo $attributeId; ?>") !== null ) {
|
| 619 |
+
_ra_voCode.push(document.getElementById("attribute<?php echo $attributeId; ?>").options[document.getElementById("attribute<?php echo $attributeId; ?>").selectedIndex].text);
|
| 620 |
+
}
|
| 621 |
+
_ra_voDetails[_ra_voCode[_ra_voCode.length - 1].replace(RegExp("[- ]", 'g'), '')] = {
|
| 622 |
+
"category_name": "<?php echo $attributeTitle; ?>",
|
| 623 |
+
"category": "<?php echo $attributeTitle; ?>",
|
| 624 |
+
"value": _ra_voCode[_ra_voCode.length - 1]
|
| 625 |
+
};
|
| 626 |
+
_ra_voCode[_ra_voCode.length - 1] = _ra_voCode[_ra_voCode.length - 1].replace(RegExp("[- ]", 'g'), '');
|
| 627 |
+
<?php endforeach ?>
|
| 628 |
+
|
| 629 |
+
var _ra_vo = {
|
| 630 |
+
"code": _ra_voCode.join('-'),
|
| 631 |
+
"details": _ra_voDetails
|
| 632 |
+
}
|
| 633 |
+
|
| 634 |
+
return _ra_vo;
|
| 635 |
+
}
|
| 636 |
+
|
| 637 |
+
_ra_helper_addLoadEvent(function() {
|
| 638 |
+
<?php foreach ($_productAttributeOptions as $_productAttribute) : ?>
|
| 639 |
+
<?php $attributeId = $_productAttribute["attribute_id"]; ?>
|
| 640 |
+
<?php $attributeTitle = $_productAttribute["label"]; ?>
|
| 641 |
+
if ( document.getElementById("attribute<?php echo $attributeId; ?>") !== null ) {
|
| 642 |
+
_ra_optElfunc[<?php echo $attributeId; ?>] = document.getElementById("attribute<?php echo $attributeId; ?>").onchange;
|
| 643 |
+
document.getElementById("attribute<?php echo $attributeId; ?>").onchange = function() {
|
| 644 |
+
if ( _ra_optElfunc[<?php echo $attributeId; ?>] !== null ) _ra_optElfunc[<?php echo $attributeId; ?>]();
|
| 645 |
+
_ra_triggerSetVariation();
|
| 646 |
+
}
|
| 647 |
+
}
|
| 648 |
+
<?php endforeach ?>
|
| 649 |
+
});
|
| 650 |
+
|
| 651 |
+
<?php endif ?>
|
| 652 |
+
|
| 653 |
+
<?php /*is configurable*/ ?>
|
| 654 |
+
<?php endif ?>
|
| 655 |
+
|
| 656 |
+
|
| 657 |
+
<?php endif ?>
|
| 658 |
+
|
| 659 |
+
|
| 660 |
+
|
| 661 |
+
<?php
|
| 662 |
+
/*
|
| 663 |
+
----------------------- Trigger addToWishlist -----------------------
|
| 664 |
+
*/
|
| 665 |
+
?>
|
| 666 |
+
<?php if ( $info = Mage::getSingleton('core/session')->getTriggerAddToWishlist() ) : ?>
|
| 667 |
+
|
| 668 |
+
// Trigger addToWishlist
|
| 669 |
+
|
| 670 |
+
<?php $referral = Mage::getSingleton('core/session')->getReferralController(); echo "/*".$referral."*/"; ?>
|
| 671 |
+
<?php if ( $referral != "product" ) : ?>
|
| 672 |
+
|
| 673 |
+
// Trigger sendProduct before addToWishlist
|
| 674 |
+
|
| 675 |
+
<?php
|
| 676 |
+
$_product = Mage::getModel('catalog/product')->load($info['product_id']);
|
| 677 |
+
$_productUrl = $_product->getProductUrl();
|
| 678 |
+
$_category = false;
|
| 679 |
+
|
| 680 |
+
$_productCategoryIds = $_product->getCategoryIds();
|
| 681 |
+
if ( count($_productCategoryIds) ) {
|
| 682 |
+
$firstCategoryId = $_productCategoryIds[0];
|
| 683 |
+
$_category = Mage::getModel('catalog/category')->load($firstCategoryId);
|
| 684 |
+
}
|
| 685 |
+
|
| 686 |
+
$_categoryParent = "false";
|
| 687 |
+
$_categoryBreadcrumb = "[]";
|
| 688 |
+
|
| 689 |
+
if($_category) {
|
| 690 |
+
if ( $_category->getLevel() > 2 ) {
|
| 691 |
+
$_categoryParent = '"'.$_category->getParentId().'"';
|
| 692 |
+
$_categoryBreadcrumb = array();
|
| 693 |
+
$breadcrumbCategory = $_category;
|
| 694 |
+
while ( $breadcrumbCategory->getLevel() > 2 ) {
|
| 695 |
+
$breadcrumbCategory = Mage::getModel('catalog/category')->load($breadcrumbCategory->getParentId());
|
| 696 |
+
|
| 697 |
+
$_categoryBreadcrumb[] = '{
|
| 698 |
+
"id": "'.$breadcrumbCategory->getId().'",
|
| 699 |
+
"name": "'.htmlspecialchars($breadcrumbCategory->getName()).'",
|
| 700 |
+
"parent": '.( $breadcrumbCategory->getLevel() > 2 ? '"'.$breadcrumbCategory->getParentId().'"' : 'false' ).'
|
| 701 |
+
}';
|
| 702 |
+
}
|
| 703 |
+
$_categoryBreadcrumb = '['.implode(', ', $_categoryBreadcrumb).']';
|
| 704 |
+
}
|
| 705 |
+
$_category = '{"id": "'.$_category->getId().'", "name": "'.htmlspecialchars($_category->getName()).'", "parent": '.$_categoryParent.'}';
|
| 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($_productUrl); ?>",
|
| 716 |
+
"img": "<?php echo htmlspecialchars(Mage::helper('catalog/image')->init($_product, 'thumbnail')); ?>",
|
| 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 |
+
"stock": <?php echo $_product->getIsInStock() ?>,
|
| 720 |
+
"brand": false,
|
| 721 |
+
"category": <?php echo $_category; ?>,
|
| 722 |
+
"category_breadcrumb": <?php echo $_categoryBreadcrumb; ?>,
|
| 723 |
+
"callback_function": function() {
|
| 724 |
+
_ra.addToWishlistInfo = {
|
| 725 |
+
"product_id": "<?php echo $info['product_id']; ?>"
|
| 726 |
+
};
|
| 727 |
+
if(typeof _ra.addToWishlist !== "undefined") _ra.addToWishlist(_ra.addToWishlistInfo.product_id);
|
| 728 |
+
}
|
| 729 |
+
};
|
| 730 |
+
|
| 731 |
+
if (_ra.ready !== undefined) {
|
| 732 |
+
if(typeof _ra.sendProduct !== "undefined") _ra.sendProduct(_ra.sendProductInfo);
|
| 733 |
+
}
|
| 734 |
+
|
| 735 |
+
<?php else : ?>
|
| 736 |
+
|
| 737 |
+
var _ra = _ra || {};
|
| 738 |
+
_ra.addToWishlistInfo = {
|
| 739 |
+
"product_id": "<?php echo $info['product_id']; ?>"
|
| 740 |
+
};
|
| 741 |
+
|
| 742 |
+
if (_ra.ready !== undefined) {
|
| 743 |
+
if(typeof _ra.addToWishlist !== "undefined") _ra.addToWishlist(_ra.addToWishlistInfo.product_id);
|
| 744 |
+
}
|
| 745 |
+
|
| 746 |
+
<?php endif ?>
|
| 747 |
+
|
| 748 |
+
<?php Mage::getSingleton('core/session')->unsTriggerAddToWishlist(); ?>
|
| 749 |
+
<?php endif ?>
|
| 750 |
+
|
| 751 |
+
|
| 752 |
+
|
| 753 |
+
<?php
|
| 754 |
+
/*
|
| 755 |
+
----------------------- Trigger clickImage -----------------------
|
| 756 |
+
*/
|
| 757 |
+
?>
|
| 758 |
+
<?php if ( Mage::app()->getFrontController()->getRequest()->getControllerName() == "product" && !is_null(Mage::registry('product')) ) : ?>
|
| 759 |
+
|
| 760 |
+
// Trigger clickImage
|
| 761 |
+
|
| 762 |
+
<?php $_product = Mage::registry('current_product'); ?>
|
| 763 |
+
|
| 764 |
+
function _ra_triggerClickImage() {
|
| 765 |
+
if(typeof _ra.clickImage !== "undefined") _ra.clickImage("<?php echo $_product->getId(); ?>");
|
| 766 |
+
}
|
| 767 |
+
|
| 768 |
+
_ra_helper_addLoadEvent(function() {
|
| 769 |
+
if ( document.getElementsByClassName("zoomWindow").length > 0 ) {
|
| 770 |
+
document.getElementsByClassName("zoomWindow")[0].onmouseover = _ra_triggerClickImage;
|
| 771 |
+
}
|
| 772 |
+
if ( document.getElementsByClassName("zoomLens").length > 0 ) {
|
| 773 |
+
document.getElementsByClassName("zoomLens")[0].onmouseover = _ra_triggerClickImage;
|
| 774 |
+
}
|
| 775 |
+
if ( document.getElementsByClassName("MagicToolboxContainer").length > 0 ) {
|
| 776 |
+
document.getElementsByClassName("MagicZoomBigImageCont")[0].onmouseover = _ra_triggerClickImage;
|
| 777 |
+
}
|
| 778 |
+
if ( document.getElementById("image") !== null ) {
|
| 779 |
+
document.getElementById("image").onclick = _ra_triggerClickImage;
|
| 780 |
+
} else if ( document.querySelector(".product-image img") !== null ) {
|
| 781 |
+
var el = document.querySelector(".product-image img").onclick = _ra_triggerClickImage;
|
| 782 |
+
}
|
| 783 |
+
});
|
| 784 |
+
|
| 785 |
+
<?php endif ?>
|
| 786 |
+
|
| 787 |
+
|
| 788 |
+
|
| 789 |
+
<?php
|
| 790 |
+
/*
|
| 791 |
+
----------------------- Trigger commentOnProduct -----------------------
|
| 792 |
+
*/
|
| 793 |
+
?>
|
| 794 |
+
<?php if ( $info = Mage::getSingleton('core/session')->getTriggerCommentOnProduct() ) : ?>
|
| 795 |
+
|
| 796 |
+
// Trigger commentOnProduct
|
| 797 |
+
|
| 798 |
+
var _ra = _ra || {};
|
| 799 |
+
_ra.commentOnProductInfo = {
|
| 800 |
+
"product_id" : "<?php echo $info['product_id']; ?>"
|
| 801 |
+
};
|
| 802 |
+
|
| 803 |
+
if (_ra.ready !== undefined) {
|
| 804 |
+
if(typeof _ra.commentOnProduct !== "undefined") _ra.commentOnProduct(_ra.commentOnProductInfo.product_id);
|
| 805 |
+
}
|
| 806 |
+
|
| 807 |
+
<?php Mage::getSingleton('core/session')->unsTriggerCommentOnProduct(); ?>
|
| 808 |
+
<?php endif ?>
|
| 809 |
+
|
| 810 |
+
|
| 811 |
+
|
| 812 |
+
<?php
|
| 813 |
+
/*
|
| 814 |
+
----------------------- Trigger mouseOverPrice -----------------------
|
| 815 |
+
*/
|
| 816 |
+
?>
|
| 817 |
+
<?php if ( Mage::app()->getFrontController()->getRequest()->getControllerName() == "product" && !is_null(Mage::registry('product')) ) : ?>
|
| 818 |
+
|
| 819 |
+
// Trigger mouseOverPrice
|
| 820 |
+
|
| 821 |
+
<?php $_product = Mage::registry('current_product'); ?>
|
| 822 |
+
|
| 823 |
+
function _ra_triggerMouseOverPrice() {
|
| 824 |
+
if(typeof _ra.mouseOverPrice !== "undefined") _ra.mouseOverPrice("<?php echo $_product->getId(); ?>", {
|
| 825 |
+
"price": <?php echo Mage::helper('tax')->getPrice($_product, $_product->getPrice()); ?>,
|
| 826 |
+
"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 ); ?>
|
| 827 |
+
});
|
| 828 |
+
}
|
| 829 |
+
|
| 830 |
+
_ra_helper_addLoadEvent(function() {
|
| 831 |
+
if ( document.getElementById("product-price-<?php echo $_product->getId(); ?>") !== null ) {
|
| 832 |
+
document.getElementById("product-price-<?php echo $_product->getId(); ?>").onmouseover = _ra_triggerMouseOverPrice;
|
| 833 |
+
}
|
| 834 |
+
if ( document.getElementById("old-price-<?php echo $_product->getId(); ?>") !== null ) {
|
| 835 |
+
document.getElementById("old-price-<?php echo $_product->getId(); ?>").onmouseover = _ra_triggerMouseOverPrice;
|
| 836 |
+
}
|
| 837 |
+
});
|
| 838 |
+
|
| 839 |
+
<?php endif ?>
|
| 840 |
+
|
| 841 |
+
|
| 842 |
+
|
| 843 |
+
<?php
|
| 844 |
+
/*
|
| 845 |
+
----------------------- Trigger mouseOverAddToCart -----------------------
|
| 846 |
+
*/
|
| 847 |
+
?>
|
| 848 |
+
<?php if ( Mage::app()->getFrontController()->getRequest()->getControllerName() == "product" && !is_null(Mage::registry('product')) ) : ?>
|
| 849 |
+
|
| 850 |
+
// Trigger mouseOverAddToCart
|
| 851 |
+
|
| 852 |
+
<?php $_product = Mage::registry('current_product'); ?>
|
| 853 |
+
|
| 854 |
+
function _ra_triggerMouseOverAddToCart() {
|
| 855 |
+
if(typeof _ra.mouseOverAddToCart !== "undefined") _ra.mouseOverAddToCart("<?php echo $_product->getId(); ?>");
|
| 856 |
+
}
|
| 857 |
+
|
| 858 |
+
_ra_helper_addLoadEvent(function() {
|
| 859 |
+
if ( document.getElementById("product-addtocart-button") !== null ) {
|
| 860 |
+
document.getElementById("product-addtocart-button").onmouseover = _ra_triggerMouseOverAddToCart;
|
| 861 |
+
} else if ( document.getElementsByClassName("btn-cart").length > 0 ) {
|
| 862 |
+
document.getElementsByClassName("btn-cart")[0].onmouseover = _ra_triggerMouseOverAddToCart;
|
| 863 |
+
}
|
| 864 |
+
});
|
| 865 |
+
|
| 866 |
+
<?php endif ?>
|
| 867 |
+
|
| 868 |
+
|
| 869 |
+
|
| 870 |
+
<?php
|
| 871 |
+
/*
|
| 872 |
+
----------------------- Trigger saveOrder -----------------------
|
| 873 |
+
*/
|
| 874 |
+
?>
|
| 875 |
+
<?php if ( $info = Mage::getSingleton('core/session')->getTriggerSaveOrder() ) : ?>
|
| 876 |
+
|
| 877 |
+
// Trigger saveOrder
|
| 878 |
+
|
| 879 |
+
var _ra = _ra || {};
|
| 880 |
+
_ra.saveOrderInfo = {
|
| 881 |
+
"order_no": "<?php echo $info['order_no']; ?>",
|
| 882 |
+
"lastname": "<?php echo htmlspecialchars($info['lastname']); ?>",
|
| 883 |
+
"firstname": "<?php echo htmlspecialchars($info['firstname']); ?>",
|
| 884 |
+
"email": "<?php echo htmlspecialchars($info['email']); ?>",
|
| 885 |
+
"phone": "<?php echo htmlspecialchars($info['phone']); ?>",
|
| 886 |
+
"state": "<?php echo htmlspecialchars($info['state']); ?>",
|
| 887 |
+
"city": "<?php echo htmlspecialchars($info['city']); ?>",
|
| 888 |
+
"address": "<?php echo htmlspecialchars($info['address']); ?>",
|
| 889 |
+
"discount": <?php echo $info['discount']; ?>,
|
| 890 |
+
"discount_code": "<?php echo $info['discount_code']; ?>",
|
| 891 |
+
"shipping": <?php echo $info['shipping']; ?>,
|
| 892 |
+
"total": <?php echo $info['total']; ?>,
|
| 893 |
+
};
|
| 894 |
+
_ra.saveOrderProducts = <?php echo $info['products']; ?>
|
| 895 |
+
|
| 896 |
+
if( _ra.ready !== undefined ){
|
| 897 |
+
if(typeof _ra.saveOrder !== "undefined") _ra.saveOrder(_ra.saveOrderInfo, _ra.saveOrderProducts);
|
| 898 |
+
}
|
| 899 |
+
|
| 900 |
+
/*
|
| 901 |
+
<?php echo $info['debug']; ?>
|
| 902 |
+
*/
|
| 903 |
+
|
| 904 |
+
<?php Mage::getSingleton('core/session')->unsTriggerSaveOrder(); ?>
|
| 905 |
+
<?php endif ?>
|
| 906 |
+
|
| 907 |
+
|
| 908 |
+
|
| 909 |
+
<?php
|
| 910 |
+
/*
|
| 911 |
+
----------------------- Trigger visitHelpPage -----------------------
|
| 912 |
+
*/
|
| 913 |
+
?>
|
| 914 |
+
<?php if ( Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms' ) : ?>
|
| 915 |
+
|
| 916 |
+
<?php
|
| 917 |
+
$page = Mage::getSingleton('cms/page');
|
| 918 |
+
$helpPages = Mage::getStoreConfig('retargetingtracker_options/more/help_pages');
|
| 919 |
+
$helpPages = explode(',', $helpPages);
|
| 920 |
+
?>
|
| 921 |
+
|
| 922 |
+
<?php if ( $page->getId() && in_array($page->getId(), $helpPages) ) : ?>
|
| 923 |
+
|
| 924 |
+
// Trigger visitHelpPage
|
| 925 |
+
|
| 926 |
+
var _ra = _ra || {};
|
| 927 |
+
_ra.visitHelpPageInfo = {
|
| 928 |
+
"visit" : true
|
| 929 |
+
}
|
| 930 |
+
|
| 931 |
+
if (_ra.ready !== undefined) {
|
| 932 |
+
if(typeof _ra.visitHelpPage !== "undefined") _ra.visitHelpPage();
|
| 933 |
+
}
|
| 934 |
+
|
| 935 |
+
<?php endif ?>
|
| 936 |
+
|
| 937 |
+
|
| 938 |
+
<?php endif ?>
|
| 939 |
+
|
| 940 |
+
|
| 941 |
+
|
| 942 |
+
<?php
|
| 943 |
+
/*
|
| 944 |
+
----------------------- Trigger checkoutIds -----------------------
|
| 945 |
+
*/
|
| 946 |
+
?>
|
| 947 |
+
<?php
|
| 948 |
+
$request = $this->getRequest();
|
| 949 |
+
$module = $request->getModuleName();
|
| 950 |
+
$controller = $request->getControllerName();
|
| 951 |
+
$action = $request->getActionName();
|
| 952 |
+
?>
|
| 953 |
+
<?php if ( ($module == 'checkout' && $controller == 'cart' && $action == 'index') || ($module == 'checkout' && $controller == 'onepage' && $action == 'index') || (Mage::getURL('checkout/onepage') == Mage::helper('core/url')->getCurrentUrl()) ) : ?>
|
| 954 |
+
|
| 955 |
+
// Trigger checkoutIds
|
| 956 |
+
|
| 957 |
+
<?php
|
| 958 |
+
$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
|
| 959 |
+
$products = array();
|
| 960 |
+
foreach($items as $item) {
|
| 961 |
+
$products[] = $item->getProductId();
|
| 962 |
+
}
|
| 963 |
+
$products = implode(", ", $products);
|
| 964 |
+
?>
|
| 965 |
+
|
| 966 |
+
var _ra = _ra || {};
|
| 967 |
+
_ra.checkoutIdsInfo = [<?php echo $products; ?>];
|
| 968 |
+
|
| 969 |
+
if (_ra.ready !== undefined) {
|
| 970 |
+
if(typeof _ra.checkoutIds !== "undefined") _ra.checkoutIds(_ra.checkoutIdsInfo);
|
| 971 |
+
}
|
| 972 |
+
|
| 973 |
+
<?php endif ?>
|
| 974 |
+
|
| 975 |
+
</script>
|
| 976 |
+
|
| 977 |
+
|
| 978 |
+
<?php
|
| 979 |
+
/*
|
| 980 |
+
----------------------- Track URL History --------------------------
|
| 981 |
+
*/
|
| 982 |
+
?>
|
| 983 |
+
<?php
|
| 984 |
+
Mage::getSingleton('core/session')->setReferralController( Mage::app()->getFrontController()->getRequest()->getControllerName() );
|
| 985 |
+
?>
|
app/etc/modules/Retargeting_Tracker.xml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* @category Retargeting
|
| 5 |
+
* @package Retargeting_Tracker
|
| 6 |
+
* @author Retargeting <info@retargeting.biz>
|
| 7 |
+
* @copyright Copyright (c) Retargeting
|
| 8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 9 |
+
*/
|
| 10 |
+
-->
|
| 11 |
+
<config>
|
| 12 |
+
<modules>
|
| 13 |
+
<Retargeting_Tracker>
|
| 14 |
+
<active>true</active>
|
| 15 |
+
<codePool>community</codePool>
|
| 16 |
+
</Retargeting_Tracker>
|
| 17 |
+
</modules>
|
| 18 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>Retargeting_Tracker</name>
|
| 4 |
+
<version>1.0.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>Retargeting and Marketing Automation. Personalized email content + Personalized live messages + SMS triggers to deliver to your customers the products they want to buy.</summary>
|
| 10 |
+
<description><h2>Retargeting and Marketing Automation</h2>
|
| 11 |
+
<p>Personalized email content + Personalized live messages + SMS triggers to deliver to your customers the products they want to buy.</p>
|
| 12 |
+
<h2>Features</h2>
|
| 13 |
+
<h3><strong>Live Triggers</strong></h3>
|
| 14 |
+
<p> When you have people in our online shop, if you see that someone's showing a lot of interest in one product, wouldn't you offer them a small discount to make sure they buy it? That's what we thought!&nbsp;<br>
|
| 15 |
+
<br>
|
| 16 |
+
With our personalized live triggers that's exactly what you'll do, just that you won't have to lift a finger.</p>
|
| 17 |
+
<p><a href="https://retargeting.biz/live-triggers-marketing" title="Live Triggers">read more about live triggers</a></p>
|
| 18 |
+
<h3><strong>E-mail triggers &amp; reminders</strong></h3>
|
| 19 |
+
<p> We all want to market someone when they're in a buying mood, but it's hard to get the right timing. But we found a secret formula and you'll have access to it through our e-mail marketing software. Someone leaves the site without finishing the order? We got your back!</p>
|
| 20 |
+
<p> Someone browsed the site, found interesting products but didn't press the buy button? We'll remind him about those cool products through a triggered email. And that's not all, we can do so much more with our personalized emails!</p>
|
| 21 |
+
<p><a href="https://retargeting.biz/email-triggers-and-reminders" title="E-mail triggers & reminders">read more about email triggers</a></p>
|
| 22 |
+
<h3><strong>SMS Triggers</strong></h3>
|
| 23 |
+
<p>Nowadays, with everyone checking their phones every 5 minutes, you can't go wrong with this, you're 100% sure that they will see your message. What better way to remind someone that they forgot to finish order a couple of hours ago?</p>
|
| 24 |
+
<p><a href="https://retargeting.biz/sms-triggers" title="SMS Triggers">read more about sms triggers</a></p>
|
| 25 |
+
<h3><strong>Multitesting</strong></h3>
|
| 26 |
+
<p>We love A/B testing so much that we created Multitesting, an improved and limitless version compared to other email marketing softwares.</p>
|
| 27 |
+
<p>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&nbsp;<a href="http://en.wikipedia.org/wiki/Marketing_automation" title="marketing automation">marketing automation</a>&nbsp;tool for your online shop!</p>
|
| 28 |
+
<p><strong>Contact</strong></p>
|
| 29 |
+
<p>For help or more info, please contact info@retargeting.biz or visit&nbsp;<a href="http://www.retargeting.biz">retargeting.biz</a>.</p></description>
|
| 30 |
+
<notes>Retargeting</notes>
|
| 31 |
+
<authors><author><name>Retargeting</name><user>retargeting</user><email>info@retargeting.biz</email></author></authors>
|
| 32 |
+
<date>2015-04-08</date>
|
| 33 |
+
<time>10:33:02</time>
|
| 34 |
+
<contents><target name="mageetc"><dir><dir name="modules"><file name="Retargeting_Tracker.xml" hash="44dbbcea34bc8ed9cc6d744176adb9a6"/></dir></dir></target><target name="magecommunity"><dir><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="4a62f578e17c5536b35b106ebcb36fde"/></dir><dir name="Model"><file name="Helppages.php" hash="51305978cda160ad7b3aa8bb8e42d3a5"/><file name="Observer.php" hash="891bb244bf9caa5d5742338cd5697ee8"/></dir><dir name="controllers"><file name="DiscountsController.php" hash="67247a363a19b6e94a33d5edfc568fa8"/><file name="IndexController.php" hash="9cbd5b979859b2014c5ed191d9b5686a"/></dir><dir name="etc"><file name="config.xml" hash="2cbad0d6a6a42b2f26e6e2046332b232"/><file name="system.xml" hash="16687c46eec71a7a48b044b8294a76eb"/></dir><dir name="sql"><dir name="retargeting_tracker_setup"><file name="mysql4-install-1.0.0.php" hash="6613b3db4b7ec61fe47f9b69591fa0c5"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir><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="764fb3c390dafdfd3a1e8cfd56962db7"/><file name="triggers.phtml" hash="5f1579688399d7e97ea691243c79051b"/></dir></dir></dir></dir></dir></dir></target></contents>
|
| 35 |
+
<compatible/>
|
| 36 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 37 |
+
</package>
|
