Version Notes
- Added Facebook retargeting integration
Download this release
Release Info
| Developer | Maxime Pruvost |
| Extension | cartsguru |
| Version | 1.3.0 |
| Comparing to | |
| See all releases | |
Code changes from version 1.2.16 to 1.3.0
- app/code/local/Cartsguru/Block/Pixel.php +41 -0
- app/code/local/Cartsguru/Helper/Data.php +1 -1
- app/code/local/Cartsguru/Helper/Tools.php +2 -2
- app/code/local/Cartsguru/Model/Catalog.php +223 -0
- app/code/local/Cartsguru/Model/Observer.php +48 -0
- app/code/local/Cartsguru/Model/Webservice.php +12 -5
- app/code/local/Cartsguru/controllers/AdminController.php +34 -0
- app/code/local/Cartsguru/controllers/CatalogController.php +10 -0
- app/code/local/Cartsguru/controllers/IndexController.php +3 -3
- app/code/local/Cartsguru/controllers/RecovercartController.php +15 -15
- app/code/local/Cartsguru/etc/config.xml +19 -1
- app/code/local/Cartsguru/sql/cartsguru_setup/upgrade-1.2.16-1.3.0.php +6 -0
- app/design/frontend/base/default/layout/cartsguru.xml +13 -2
- app/design/frontend/base/default/template/cartsguru/checkout/purchase.phtml +26 -0
- app/design/frontend/base/default/template/cartsguru/pixel.phtml +32 -0
- app/design/frontend/base/default/template/cartsguru/product/view.phtml +23 -0
- package.xml +5 -5
app/code/local/Cartsguru/Block/Pixel.php
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Cartsguru_Block_Pixel extends Mage_Core_Block_Template
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* Check if Facebook is enabled
|
| 7 |
+
*/
|
| 8 |
+
protected function isFacebookEnabled()
|
| 9 |
+
{
|
| 10 |
+
return Mage::getStoreConfig("cartsguru/cartsguru_group/feature_facebook");
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
/**
|
| 14 |
+
* Get FB pixel from config
|
| 15 |
+
*/
|
| 16 |
+
protected function getPixel()
|
| 17 |
+
{
|
| 18 |
+
return Mage::getStoreConfig("cartsguru/cartsguru_group/facebook_pixel");
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* Get CatalogId from config
|
| 23 |
+
*/
|
| 24 |
+
protected function getCatalogId()
|
| 25 |
+
{
|
| 26 |
+
return Mage::getStoreConfig("cartsguru/cartsguru_group/facebook_catalogId");
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* Get the product added to cart that we saved in session
|
| 31 |
+
*/
|
| 32 |
+
protected function getAddToCartProduct()
|
| 33 |
+
{
|
| 34 |
+
$productData = Mage::getSingleton('core/session')->getCartsGuruAddToCart();
|
| 35 |
+
if ($productData) {
|
| 36 |
+
Mage::getSingleton('core/session')->unsCartsGuruAddToCart();
|
| 37 |
+
return $productData;
|
| 38 |
+
}
|
| 39 |
+
return false;
|
| 40 |
+
}
|
| 41 |
+
}
|
app/code/local/Cartsguru/Helper/Data.php
CHANGED
|
@@ -46,4 +46,4 @@
|
|
| 46 |
}
|
| 47 |
return false;
|
| 48 |
}
|
| 49 |
-
|
| 46 |
}
|
| 47 |
return false;
|
| 48 |
}
|
| 49 |
+
}
|
app/code/local/Cartsguru/Helper/Tools.php
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
* Class Cartsguru_Helper_Tools
|
| 5 |
*/
|
| 6 |
class Cartsguru_Helper_Tools {
|
| 7 |
-
|
| 8 |
/**
|
| 9 |
* This method generate a random uuid v4
|
| 10 |
* @param $customer
|
|
@@ -31,4 +31,4 @@ class Cartsguru_Helper_Tools {
|
|
| 31 |
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
|
| 32 |
);
|
| 33 |
}
|
| 34 |
-
}
|
| 4 |
* Class Cartsguru_Helper_Tools
|
| 5 |
*/
|
| 6 |
class Cartsguru_Helper_Tools {
|
| 7 |
+
|
| 8 |
/**
|
| 9 |
* This method generate a random uuid v4
|
| 10 |
* @param $customer
|
| 31 |
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
|
| 32 |
);
|
| 33 |
}
|
| 34 |
+
}
|
app/code/local/Cartsguru/Model/Catalog.php
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* This class generates catalog feed for Facebook
|
| 5 |
+
* Class Cartsguru_Model_Catalog
|
| 6 |
+
*/
|
| 7 |
+
class Cartsguru_Model_Catalog {
|
| 8 |
+
|
| 9 |
+
/**
|
| 10 |
+
* @var XMLWriter
|
| 11 |
+
*/
|
| 12 |
+
protected $doc;
|
| 13 |
+
|
| 14 |
+
/**
|
| 15 |
+
* The fields to be put into the feed.
|
| 16 |
+
* @var array
|
| 17 |
+
*/
|
| 18 |
+
protected $_requiredFields = array(
|
| 19 |
+
array(
|
| 20 |
+
'magento' => 'id',
|
| 21 |
+
'feed' => 'g:id',
|
| 22 |
+
'type' => 'id',
|
| 23 |
+
),
|
| 24 |
+
array(
|
| 25 |
+
'magento' => 'availability_google',
|
| 26 |
+
'feed' => 'g:availability',
|
| 27 |
+
'type' => 'computed',
|
| 28 |
+
),
|
| 29 |
+
// condition here
|
| 30 |
+
array(
|
| 31 |
+
'magento' => 'description',
|
| 32 |
+
'feed' => 'g:description',
|
| 33 |
+
'type' => 'product_attribute',
|
| 34 |
+
),
|
| 35 |
+
array(
|
| 36 |
+
'magento' => 'image_url',
|
| 37 |
+
'feed' => 'g:image_link',
|
| 38 |
+
'type' => 'computed',
|
| 39 |
+
),
|
| 40 |
+
array(
|
| 41 |
+
'magento' => 'product_link',
|
| 42 |
+
'feed' => 'g:link',
|
| 43 |
+
'type' => 'computed',
|
| 44 |
+
),
|
| 45 |
+
array(
|
| 46 |
+
'magento' => 'name',
|
| 47 |
+
'feed' => 'g:title',
|
| 48 |
+
'type' => 'product_attribute',
|
| 49 |
+
),
|
| 50 |
+
array(
|
| 51 |
+
'magento' => 'manufacturer',
|
| 52 |
+
'feed' => 'g:brand',
|
| 53 |
+
'type' => 'product_attribute',
|
| 54 |
+
),
|
| 55 |
+
array(
|
| 56 |
+
'magento' => 'price',
|
| 57 |
+
'feed' => 'g:price',
|
| 58 |
+
'type' => 'computed',
|
| 59 |
+
)
|
| 60 |
+
);
|
| 61 |
+
|
| 62 |
+
/*
|
| 63 |
+
* Generate XML product feed
|
| 64 |
+
*/
|
| 65 |
+
public function generateFeed()
|
| 66 |
+
{
|
| 67 |
+
// setup attribute mapping
|
| 68 |
+
$this->_attributes = array();
|
| 69 |
+
foreach ($this->_requiredFields as $requiredField) {
|
| 70 |
+
$this->_attributes[$requiredField['feed']] = $requiredField;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
$this->setupHeader(Mage::app()->getStore());
|
| 74 |
+
$productCollection = Mage::getResourceModel('catalog/product_collection');
|
| 75 |
+
$productCollection->addStoreFilter();
|
| 76 |
+
|
| 77 |
+
$this->_products = array();
|
| 78 |
+
Mage::getSingleton('core/resource_iterator')->walk($productCollection->getSelect(), array(array($this, 'processProduct')));
|
| 79 |
+
|
| 80 |
+
$this->setupFooter();
|
| 81 |
+
|
| 82 |
+
return $this->doc->flush();
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
/*
|
| 86 |
+
* Process each product in a loop
|
| 87 |
+
*/
|
| 88 |
+
public function processProduct($args)
|
| 89 |
+
{
|
| 90 |
+
$product = Mage::getModel('catalog/product')->load($args['row']['entity_id']);
|
| 91 |
+
|
| 92 |
+
$product_data = array();
|
| 93 |
+
$attributes = $this->_attributes;
|
| 94 |
+
// store
|
| 95 |
+
$store = Mage::getModel('core/store')->load($product->getStoreId());
|
| 96 |
+
// Prepare attributes
|
| 97 |
+
foreach ($attributes as $attribute) {
|
| 98 |
+
if ($attribute['type'] == 'id') {
|
| 99 |
+
$value = $product->getId();
|
| 100 |
+
} elseif ($attribute['type'] == 'product_attribute') {
|
| 101 |
+
// if this is a normal product attribute, retrieve it's frontend representation
|
| 102 |
+
if ($product->getData($attribute['magento']) === null) {
|
| 103 |
+
$value = '';
|
| 104 |
+
} else {
|
| 105 |
+
/** @var $attributeObj Mage_Catalog_Model_Resource_Eav_Attribute */
|
| 106 |
+
$attributeObj = $product->getResource()->getAttribute($attribute['magento']);
|
| 107 |
+
$value = $attributeObj->getFrontend()->getValue($product);
|
| 108 |
+
}
|
| 109 |
+
} elseif ($attribute['type'] == 'computed') {
|
| 110 |
+
// if this is a computed attribute, handle it depending on its code
|
| 111 |
+
switch ($attribute['magento']) {
|
| 112 |
+
case 'price':
|
| 113 |
+
$price = Mage::helper('tax')->getPrice($product, $product->getFinalPrice(), true);
|
| 114 |
+
$value = sprintf('%.2f', (float)($store->convertPrice($price, false, false)));
|
| 115 |
+
$value .= ' '.Mage::getStoreConfig('currency/options/default', $product->getStoreId());
|
| 116 |
+
break;
|
| 117 |
+
|
| 118 |
+
case 'product_link':
|
| 119 |
+
$value = $product->getProductUrl();
|
| 120 |
+
break;
|
| 121 |
+
|
| 122 |
+
case 'image_url':
|
| 123 |
+
$value = (string)Mage::helper('catalog/image')->init($product, 'image');
|
| 124 |
+
break;
|
| 125 |
+
|
| 126 |
+
case 'availability_google':
|
| 127 |
+
$value = $product->isSaleable() ? 'in stock' : 'out of stock';
|
| 128 |
+
break;
|
| 129 |
+
|
| 130 |
+
default:
|
| 131 |
+
$value = '';
|
| 132 |
+
}
|
| 133 |
+
}
|
| 134 |
+
$product_data[$attribute['feed']] = $value;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
$price = floatval($product_data['g:price']);
|
| 138 |
+
// Price is required
|
| 139 |
+
if (empty($price)) {
|
| 140 |
+
return;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
// If manufacturer not set use mpn === sku
|
| 144 |
+
if ($product_data['g:brand'] === '') {
|
| 145 |
+
unset($product_data['g:brand']);
|
| 146 |
+
$product_data['g:mpn'] = $product_data['g:id'];
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
// All products are new
|
| 150 |
+
$product_data['g:condition'] = 'new';
|
| 151 |
+
|
| 152 |
+
// Sart new feed entry
|
| 153 |
+
$this->doc->startElement('entry');
|
| 154 |
+
|
| 155 |
+
foreach ($product_data as $feedTag => $value) {
|
| 156 |
+
$safeString = null;
|
| 157 |
+
switch ($feedTag) {
|
| 158 |
+
case 'g:link':
|
| 159 |
+
$safeString = $value;
|
| 160 |
+
break;
|
| 161 |
+
|
| 162 |
+
case 'g:price':
|
| 163 |
+
$safeString = sprintf('%.2f', $store->convertPrice($value, false, false)).' '.Mage::getStoreConfig('currency/options/default', $store->getStoreId());
|
| 164 |
+
break;
|
| 165 |
+
|
| 166 |
+
case 'g:sale_price':
|
| 167 |
+
if($value && $value != ''){
|
| 168 |
+
$safeString = sprintf('%.2f', $store->convertPrice($value, false, false)).' '.Mage::getStoreConfig('currency/options/default', $store->getStoreId());
|
| 169 |
+
}
|
| 170 |
+
break;
|
| 171 |
+
|
| 172 |
+
case 'g:image_link':
|
| 173 |
+
if ($value == 'no_selection') {
|
| 174 |
+
$safeString = '';
|
| 175 |
+
} else {
|
| 176 |
+
$safeString = $value;
|
| 177 |
+
// Check if the link is a full URL
|
| 178 |
+
if (substr($value, 0, 5) != 'http:' && substr($value, 0, 6) != 'https:') {
|
| 179 |
+
$safeString = $store->getBaseUrl('media') . 'catalog/product' . $value;
|
| 180 |
+
}
|
| 181 |
+
}
|
| 182 |
+
break;
|
| 183 |
+
|
| 184 |
+
default:
|
| 185 |
+
$safeString = $value;
|
| 186 |
+
break;
|
| 187 |
+
}
|
| 188 |
+
if ($safeString !== null) {
|
| 189 |
+
$this->doc->writeElement($feedTag, $safeString);
|
| 190 |
+
}
|
| 191 |
+
}
|
| 192 |
+
$this->doc->endElement();
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
/*
|
| 196 |
+
* Instantiate the XML object
|
| 197 |
+
*/
|
| 198 |
+
protected function setupHeader($store)
|
| 199 |
+
{
|
| 200 |
+
$this->doc = new XMLWriter();
|
| 201 |
+
$this->doc->openMemory();
|
| 202 |
+
$this->doc->setIndent(true);
|
| 203 |
+
$this->doc->setIndentString(' ');
|
| 204 |
+
$this->doc->startDocument('1.0', 'UTF-8');
|
| 205 |
+
$this->doc->startElement('feed');
|
| 206 |
+
$this->doc->writeAttribute('xmlns', 'http://www.w3.org/2005/Atom');
|
| 207 |
+
$this->doc->writeAttribute('xmlns:g', 'http://base.google.com/ns/1.0');
|
| 208 |
+
$this->doc->writeElement('title', $store->getName());
|
| 209 |
+
$this->doc->startElement('link');
|
| 210 |
+
$this->doc->writeAttribute('rel', 'self');
|
| 211 |
+
$this->doc->writeAttribute('href', $store->getBaseUrl());
|
| 212 |
+
$this->doc->endElement();
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
/*
|
| 216 |
+
* Close the XML object
|
| 217 |
+
*/
|
| 218 |
+
protected function setupFooter()
|
| 219 |
+
{
|
| 220 |
+
$this->doc->endElement();
|
| 221 |
+
$this->doc->endDocument();
|
| 222 |
+
}
|
| 223 |
+
}
|
app/code/local/Cartsguru/Model/Observer.php
CHANGED
|
@@ -99,4 +99,52 @@ class Cartsguru_Model_Observer
|
|
| 99 |
|
| 100 |
Mage::log('Observer: End handle orderSaveAfter for ' . $order->getIncrementId(), null, Cartsguru_Model_Observer::LOG_FILE);
|
| 101 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
}
|
| 99 |
|
| 100 |
Mage::log('Observer: End handle orderSaveAfter for ' . $order->getIncrementId(), null, Cartsguru_Model_Observer::LOG_FILE);
|
| 101 |
}
|
| 102 |
+
|
| 103 |
+
/**
|
| 104 |
+
* Saves added product data to fire FB pixel
|
| 105 |
+
* @param $observer
|
| 106 |
+
*/
|
| 107 |
+
public function checkoutCartAdd($observer) {
|
| 108 |
+
$facebook_enabled = Mage::getStoreConfig("cartsguru/cartsguru_group/feature_facebook");
|
| 109 |
+
if ($facebook_enabled) {
|
| 110 |
+
// Laod product
|
| 111 |
+
$product = Mage::getModel('catalog/product')
|
| 112 |
+
->load(Mage::app()->getRequest()->getParam('product', 0));
|
| 113 |
+
|
| 114 |
+
if (!$product->getId()) {
|
| 115 |
+
return;
|
| 116 |
+
}
|
| 117 |
+
$price = $product->getPrice();
|
| 118 |
+
if (!$price) {
|
| 119 |
+
$price = $product->getSpecialPrice();
|
| 120 |
+
}
|
| 121 |
+
// Save product data into session
|
| 122 |
+
Mage::getSingleton('core/session')->setCartsGuruAddToCart(
|
| 123 |
+
new Varien_Object(array(
|
| 124 |
+
'id' => $product->getId(),
|
| 125 |
+
'price' => number_format((double)$price, 2, '.', ',')
|
| 126 |
+
))
|
| 127 |
+
);
|
| 128 |
+
}
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
/**
|
| 132 |
+
* Check if we have source query param ans set the cookie
|
| 133 |
+
* @param $observer
|
| 134 |
+
*/
|
| 135 |
+
public function checkSource($observer) {
|
| 136 |
+
$utm_source = Mage::app()->getRequest()->getParam('utm_source');
|
| 137 |
+
$utm_campaign = Mage::app()->getRequest()->getParam('utm_campaign');
|
| 138 |
+
if ($utm_source && $utm_campaign) {
|
| 139 |
+
if (!empty($utm_source) && $utm_source === 'cartsguru-fb' && !empty($utm_campaign)) {
|
| 140 |
+
$cookie = Mage::getSingleton('core/cookie');
|
| 141 |
+
$ttl = 60 * 60 * 24 * 30; // 1 month
|
| 142 |
+
$cookie->set('cartsguru-source', serialize(array(
|
| 143 |
+
'type' => $utm_source,
|
| 144 |
+
'campaign' => $utm_campaign,
|
| 145 |
+
'timestamp' => time()
|
| 146 |
+
)), $ttl, '/');
|
| 147 |
+
}
|
| 148 |
+
}
|
| 149 |
+
}
|
| 150 |
}
|
app/code/local/Cartsguru/Model/Webservice.php
CHANGED
|
@@ -17,7 +17,7 @@ class Cartsguru_Model_Webservice
|
|
| 17 |
const QUOTES_CACHE_TAG = 'cartsguru_carts';
|
| 18 |
const QUOTES_CACHE_TTL = 1800; // 30min in seconds
|
| 19 |
|
| 20 |
-
const _CARTSGURU_VERSION_ = '1.
|
| 21 |
|
| 22 |
protected function getStoreFromAdmin(){
|
| 23 |
$store_id = null;
|
|
@@ -43,7 +43,7 @@ class Cartsguru_Model_Webservice
|
|
| 43 |
}
|
| 44 |
}
|
| 45 |
|
| 46 |
-
|
| 47 |
{
|
| 48 |
if (!$store){
|
| 49 |
$store = Mage::app()->getStore();
|
|
@@ -52,7 +52,7 @@ class Cartsguru_Model_Webservice
|
|
| 52 |
$store->setConfig($this->configBasePath . $key, $value);
|
| 53 |
}
|
| 54 |
|
| 55 |
-
|
| 56 |
if (!$store){
|
| 57 |
$store = Mage::app()->getStore();
|
| 58 |
}
|
|
@@ -60,7 +60,7 @@ class Cartsguru_Model_Webservice
|
|
| 60 |
return $store->getConfig($this->configBasePath . $key);
|
| 61 |
}
|
| 62 |
|
| 63 |
-
|
| 64 |
if (!$store){
|
| 65 |
$store = Mage::app()->getStore();
|
| 66 |
}
|
|
@@ -284,6 +284,13 @@ class Cartsguru_Model_Webservice
|
|
| 284 |
return;
|
| 285 |
}
|
| 286 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 287 |
//Push data to api
|
| 288 |
$this->doPostRequest('/orders', $orderData, $store);
|
| 289 |
}
|
|
@@ -522,7 +529,7 @@ class Cartsguru_Model_Webservice
|
|
| 522 |
$fields = array(
|
| 523 |
'plugin' => 'magento',
|
| 524 |
'pluginVersion' => Cartsguru_Model_Webservice::_CARTSGURU_VERSION_,
|
| 525 |
-
'
|
| 526 |
);
|
| 527 |
|
| 528 |
$response = $this->doPostRequest($requestUrl, $fields, $store, true);
|
| 17 |
const QUOTES_CACHE_TAG = 'cartsguru_carts';
|
| 18 |
const QUOTES_CACHE_TTL = 1800; // 30min in seconds
|
| 19 |
|
| 20 |
+
const _CARTSGURU_VERSION_ = '1.3.0';
|
| 21 |
|
| 22 |
protected function getStoreFromAdmin(){
|
| 23 |
$store_id = null;
|
| 43 |
}
|
| 44 |
}
|
| 45 |
|
| 46 |
+
public function setStoreConfig($key, $value, $store = null)
|
| 47 |
{
|
| 48 |
if (!$store){
|
| 49 |
$store = Mage::app()->getStore();
|
| 52 |
$store->setConfig($this->configBasePath . $key, $value);
|
| 53 |
}
|
| 54 |
|
| 55 |
+
public function getStoreConfig($key, $store = null){
|
| 56 |
if (!$store){
|
| 57 |
$store = Mage::app()->getStore();
|
| 58 |
}
|
| 60 |
return $store->getConfig($this->configBasePath . $key);
|
| 61 |
}
|
| 62 |
|
| 63 |
+
public function isStoreConfigured($store = null){
|
| 64 |
if (!$store){
|
| 65 |
$store = Mage::app()->getStore();
|
| 66 |
}
|
| 284 |
return;
|
| 285 |
}
|
| 286 |
|
| 287 |
+
// Check for source cookie
|
| 288 |
+
$source = Mage::getSingleton('core/cookie')->get('cartsguru-source');
|
| 289 |
+
if (!empty($source)) {
|
| 290 |
+
$orderData['source'] = unserialize($source);
|
| 291 |
+
Mage::getSingleton('core/cookie')->delete('cartsguru-source');
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
//Push data to api
|
| 295 |
$this->doPostRequest('/orders', $orderData, $store);
|
| 296 |
}
|
| 529 |
$fields = array(
|
| 530 |
'plugin' => 'magento',
|
| 531 |
'pluginVersion' => Cartsguru_Model_Webservice::_CARTSGURU_VERSION_,
|
| 532 |
+
'adminUrl' => Mage::getBaseUrl() . 'cartsguru/admin?cartsguru_admin_action='
|
| 533 |
);
|
| 534 |
|
| 535 |
$response = $this->doPostRequest($requestUrl, $fields, $store, true);
|
app/code/local/Cartsguru/controllers/AdminController.php
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Cartsguru_AdminController extends Mage_Core_Controller_Front_Action {
|
| 4 |
+
|
| 5 |
+
public function indexAction(){
|
| 6 |
+
$params = $this->getRequest()->getParams();
|
| 7 |
+
$webservice = Mage::getModel('cartsguru/webservice');
|
| 8 |
+
$store = Mage::app()->getWebsite(true)->getDefaultGroup()->getDefaultStore();
|
| 9 |
+
$auth_key = $webservice->getStoreConfig('auth', $store);
|
| 10 |
+
// Stop if no enoguth params
|
| 11 |
+
if (!isset($params['cartsguru_admin_action']) || !isset($params['cartsguru_auth_key']) || $auth_key !== $params['cartsguru_auth_key']){
|
| 12 |
+
die;
|
| 13 |
+
}
|
| 14 |
+
// Toggle features action
|
| 15 |
+
if ($params['cartsguru_admin_action'] === 'toggleFeatures' && isset($params['cartsguru_admin_data'])) {
|
| 16 |
+
$data = json_decode($params['cartsguru_admin_data'], true);
|
| 17 |
+
if (is_array($data)) {
|
| 18 |
+
// Enable facebook
|
| 19 |
+
if ($data['facebook'] && $data['catalogId'] && $data['pixel']) {
|
| 20 |
+
// Save facebook pixel
|
| 21 |
+
Mage::getConfig()->saveConfig('cartsguru/cartsguru_group/feature_facebook', true);
|
| 22 |
+
Mage::getConfig()->saveConfig('cartsguru/cartsguru_group/facebook_pixel', $data['pixel']);
|
| 23 |
+
Mage::getConfig()->saveConfig('cartsguru/cartsguru_group/facebook_catalogId', $data['catalogId']);
|
| 24 |
+
// return catalogUrl
|
| 25 |
+
header('Content-Type: application/json; charset=utf-8');
|
| 26 |
+
echo json_encode(array('catalogUrl' => Mage::getBaseUrl() . 'cartsguru/catalog'));
|
| 27 |
+
die;
|
| 28 |
+
} elseif ($data['facebook'] == false) {
|
| 29 |
+
Mage::getConfig()->saveConfig('cartsguru/cartsguru_group/feature_facebook', false);
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
}
|
app/code/local/Cartsguru/controllers/CatalogController.php
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Cartsguru_CatalogController extends Mage_Core_Controller_Front_Action {
|
| 4 |
+
|
| 5 |
+
public function indexAction(){
|
| 6 |
+
$catalog = Mage::getModel('cartsguru/catalog');
|
| 7 |
+
header('Content-Type: application/xml; charset=utf-8');
|
| 8 |
+
echo $catalog->generateFeed();
|
| 9 |
+
}
|
| 10 |
+
}
|
app/code/local/Cartsguru/controllers/IndexController.php
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
<?php
|
| 2 |
|
| 3 |
-
class Cartsguru_IndexController extends Mage_Core_Controller_Front_Action {
|
| 4 |
-
|
| 5 |
public function indexAction(){
|
| 6 |
echo 'Visit https://carts.guru';
|
| 7 |
}
|
| 8 |
-
}
|
| 1 |
<?php
|
| 2 |
|
| 3 |
+
class Cartsguru_IndexController extends Mage_Core_Controller_Front_Action {
|
| 4 |
+
|
| 5 |
public function indexAction(){
|
| 6 |
echo 'Visit https://carts.guru';
|
| 7 |
}
|
| 8 |
+
}
|
app/code/local/Cartsguru/controllers/RecovercartController.php
CHANGED
|
@@ -1,21 +1,21 @@
|
|
| 1 |
<?php
|
| 2 |
|
| 3 |
-
class Cartsguru_RecovercartController extends Mage_Core_Controller_Front_Action {
|
| 4 |
-
|
| 5 |
private function redirectToCart() {
|
| 6 |
$url = Mage::helper('checkout/cart')->getCartUrl();
|
| 7 |
$this->getResponse()->setRedirect($url)->sendResponse();
|
| 8 |
}
|
| 9 |
-
|
| 10 |
public function indexAction(){
|
| 11 |
// Get request params
|
| 12 |
$params = $this->getRequest()->getParams();
|
| 13 |
-
|
| 14 |
// Stop if no enoguth params
|
| 15 |
if (!isset($params['cart_id']) || !isset($params['cart_token'])){
|
| 16 |
return $this->redirectToCart();
|
| 17 |
}
|
| 18 |
-
|
| 19 |
// Load quote by id
|
| 20 |
$quote = Mage::getModel('sales/quote')->load($params['cart_id']);
|
| 21 |
|
|
@@ -23,25 +23,25 @@ class Cartsguru_RecovercartController extends Mage_Core_Controller_Front_Action
|
|
| 23 |
if (!$quote->getId()){
|
| 24 |
return $this->redirectToCart();
|
| 25 |
}
|
| 26 |
-
|
| 27 |
// Check quote token
|
| 28 |
$token = $quote->getData('cartsguru_token');
|
| 29 |
if (!$token || $token != $params['cart_token']){
|
| 30 |
return $this->redirectToCart();
|
| 31 |
}
|
| 32 |
-
|
| 33 |
// Auto log customer if we can
|
| 34 |
if ($quote->getCustomerId()){
|
| 35 |
//Gest customer
|
| 36 |
$customer = Mage::getModel('customer/customer')->load($quote->getCustomerId());
|
| 37 |
-
|
| 38 |
Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer);
|
| 39 |
}
|
| 40 |
else {
|
| 41 |
-
// Get current cart
|
| 42 |
$cart = Mage::getSingleton('checkout/cart');
|
| 43 |
-
|
| 44 |
-
|
| 45 |
foreach ($cart->getQuote()->getAllVisibleItems() as $item) {
|
| 46 |
$found = false;
|
| 47 |
foreach ($quote->getAllItems() as $quoteItem) {
|
|
@@ -51,7 +51,7 @@ class Cartsguru_RecovercartController extends Mage_Core_Controller_Front_Action
|
|
| 51 |
break;
|
| 52 |
}
|
| 53 |
}
|
| 54 |
-
|
| 55 |
if (!$found) {
|
| 56 |
$newItem = clone $item;
|
| 57 |
$quote->addItem($newItem);
|
|
@@ -64,14 +64,14 @@ class Cartsguru_RecovercartController extends Mage_Core_Controller_Front_Action
|
|
| 64 |
}
|
| 65 |
}
|
| 66 |
}
|
| 67 |
-
|
| 68 |
$quote->save();
|
| 69 |
$cart->setQuote($quote);
|
| 70 |
$cart->init();
|
| 71 |
$cart->save();
|
| 72 |
}
|
| 73 |
-
|
| 74 |
// Redirect to checkout
|
| 75 |
return $this->redirectToCart();
|
| 76 |
}
|
| 77 |
-
}
|
| 1 |
<?php
|
| 2 |
|
| 3 |
+
class Cartsguru_RecovercartController extends Mage_Core_Controller_Front_Action {
|
| 4 |
+
|
| 5 |
private function redirectToCart() {
|
| 6 |
$url = Mage::helper('checkout/cart')->getCartUrl();
|
| 7 |
$this->getResponse()->setRedirect($url)->sendResponse();
|
| 8 |
}
|
| 9 |
+
|
| 10 |
public function indexAction(){
|
| 11 |
// Get request params
|
| 12 |
$params = $this->getRequest()->getParams();
|
| 13 |
+
|
| 14 |
// Stop if no enoguth params
|
| 15 |
if (!isset($params['cart_id']) || !isset($params['cart_token'])){
|
| 16 |
return $this->redirectToCart();
|
| 17 |
}
|
| 18 |
+
|
| 19 |
// Load quote by id
|
| 20 |
$quote = Mage::getModel('sales/quote')->load($params['cart_id']);
|
| 21 |
|
| 23 |
if (!$quote->getId()){
|
| 24 |
return $this->redirectToCart();
|
| 25 |
}
|
| 26 |
+
|
| 27 |
// Check quote token
|
| 28 |
$token = $quote->getData('cartsguru_token');
|
| 29 |
if (!$token || $token != $params['cart_token']){
|
| 30 |
return $this->redirectToCart();
|
| 31 |
}
|
| 32 |
+
|
| 33 |
// Auto log customer if we can
|
| 34 |
if ($quote->getCustomerId()){
|
| 35 |
//Gest customer
|
| 36 |
$customer = Mage::getModel('customer/customer')->load($quote->getCustomerId());
|
| 37 |
+
|
| 38 |
Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer);
|
| 39 |
}
|
| 40 |
else {
|
| 41 |
+
// Get current cart
|
| 42 |
$cart = Mage::getSingleton('checkout/cart');
|
| 43 |
+
|
| 44 |
+
|
| 45 |
foreach ($cart->getQuote()->getAllVisibleItems() as $item) {
|
| 46 |
$found = false;
|
| 47 |
foreach ($quote->getAllItems() as $quoteItem) {
|
| 51 |
break;
|
| 52 |
}
|
| 53 |
}
|
| 54 |
+
|
| 55 |
if (!$found) {
|
| 56 |
$newItem = clone $item;
|
| 57 |
$quote->addItem($newItem);
|
| 64 |
}
|
| 65 |
}
|
| 66 |
}
|
| 67 |
+
|
| 68 |
$quote->save();
|
| 69 |
$cart->setQuote($quote);
|
| 70 |
$cart->init();
|
| 71 |
$cart->save();
|
| 72 |
}
|
| 73 |
+
|
| 74 |
// Redirect to checkout
|
| 75 |
return $this->redirectToCart();
|
| 76 |
}
|
| 77 |
+
}
|
app/code/local/Cartsguru/etc/config.xml
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
<!-- plugin name -->
|
| 4 |
<modules>
|
| 5 |
<Cartsguru>
|
| 6 |
-
<version>1.
|
| 7 |
</Cartsguru>
|
| 8 |
</modules>
|
| 9 |
<global>
|
|
@@ -126,6 +126,24 @@
|
|
| 126 |
</args>
|
| 127 |
</cartsguru>
|
| 128 |
</routers>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
<layout>
|
| 130 |
<updates>
|
| 131 |
<cartsguru>
|
| 3 |
<!-- plugin name -->
|
| 4 |
<modules>
|
| 5 |
<Cartsguru>
|
| 6 |
+
<version>1.3.0</version>
|
| 7 |
</Cartsguru>
|
| 8 |
</modules>
|
| 9 |
<global>
|
| 126 |
</args>
|
| 127 |
</cartsguru>
|
| 128 |
</routers>
|
| 129 |
+
<events>
|
| 130 |
+
<controller_front_send_response_before>
|
| 131 |
+
<observers>
|
| 132 |
+
<cartsguru>
|
| 133 |
+
<class>Cartsguru_Model_Observer</class>
|
| 134 |
+
<method>checkSource</method>
|
| 135 |
+
</cartsguru>
|
| 136 |
+
</observers>
|
| 137 |
+
</controller_front_send_response_before>
|
| 138 |
+
<controller_action_predispatch_checkout_cart_add>
|
| 139 |
+
<observers>
|
| 140 |
+
<cartsguru>
|
| 141 |
+
<class>Cartsguru_Model_Observer</class>
|
| 142 |
+
<method>checkoutCartAdd</method>
|
| 143 |
+
</cartsguru>
|
| 144 |
+
</observers>
|
| 145 |
+
</controller_action_predispatch_checkout_cart_add>
|
| 146 |
+
</events>
|
| 147 |
<layout>
|
| 148 |
<updates>
|
| 149 |
<cartsguru>
|
app/code/local/Cartsguru/sql/cartsguru_setup/upgrade-1.2.16-1.3.0.php
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
| 3 |
+
$installer = $this;
|
| 4 |
+
|
| 5 |
+
$installer->startSetup();
|
| 6 |
+
$installer->endSetup();
|
app/design/frontend/base/default/layout/cartsguru.xml
CHANGED
|
@@ -1,8 +1,19 @@
|
|
| 1 |
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
<layout version="1.0.0">
|
| 3 |
-
<default
|
| 4 |
<reference name="head">
|
| 5 |
<action method="addJs"><script>cartsguru/checkout.js</script></action>
|
|
|
|
| 6 |
</reference>
|
| 7 |
</default>
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
<layout version="1.0.0">
|
| 3 |
+
<default>
|
| 4 |
<reference name="head">
|
| 5 |
<action method="addJs"><script>cartsguru/checkout.js</script></action>
|
| 6 |
+
<block type="cartsguru/pixel" name="cartsguru_pixel" template="cartsguru/pixel.phtml"/>
|
| 7 |
</reference>
|
| 8 |
</default>
|
| 9 |
+
<catalog_product_view>
|
| 10 |
+
<reference name="after_body_start">
|
| 11 |
+
<block type="cartsguru/pixel" name="cartsguru_pixel_productview" template="cartsguru/product/view.phtml" />
|
| 12 |
+
</reference>
|
| 13 |
+
</catalog_product_view>
|
| 14 |
+
<checkout_onepage_success translate="label">
|
| 15 |
+
<reference name="after_body_start">
|
| 16 |
+
<block type="cartsguru/pixel" name="cartsguru_pixel_purchase" template="cartsguru/checkout/purchase.phtml"/>
|
| 17 |
+
</reference>
|
| 18 |
+
</checkout_onepage_success>
|
| 19 |
+
</layout>
|
app/design/frontend/base/default/template/cartsguru/checkout/purchase.phtml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$facebookEnabled = $this->isFacebookEnabled();
|
| 3 |
+
$pixel = $this->getPixel();
|
| 4 |
+
$catalogId = $this->getCatalogId();
|
| 5 |
+
$lastOrder = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId());
|
| 6 |
+
|
| 7 |
+
if ($facebookEnabled && $pixel && $catalogId && $lastOrder):
|
| 8 |
+
$items = $lastOrder->getAllVisibleItems();
|
| 9 |
+
$productIds = array();
|
| 10 |
+
|
| 11 |
+
foreach ($items as $item) {
|
| 12 |
+
array_push($productIds, $item->getId());
|
| 13 |
+
}
|
| 14 |
+
$total = number_format((double)$lastOrder->getGrandTotal(), 2, '.', '');
|
| 15 |
+
?>
|
| 16 |
+
<script>
|
| 17 |
+
fbq('track', 'Purchase', {
|
| 18 |
+
content_ids: <?php echo Zend_Json::encode($productIds); ?>,
|
| 19 |
+
content_type: 'product',
|
| 20 |
+
value: <?php echo $total; ?>,
|
| 21 |
+
currency: '<?php echo Mage::app()->getStore()->getCurrentCurrencyCode(); ?>',
|
| 22 |
+
product_catalog_id: '<?php echo $catalogId; ?>'
|
| 23 |
+
});
|
| 24 |
+
</script>
|
| 25 |
+
|
| 26 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/cartsguru/pixel.phtml
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$facebookEnabled = $this->isFacebookEnabled();
|
| 3 |
+
$cartProduct = $this->getAddToCartProduct();
|
| 4 |
+
$pixel = $this->getPixel();
|
| 5 |
+
$catalogId = $this->getCatalogId();
|
| 6 |
+
?>
|
| 7 |
+
<?php if ($facebookEnabled && $pixel && $catalogId): ?>
|
| 8 |
+
<!-- Facebook Pixel Code -->
|
| 9 |
+
<script>
|
| 10 |
+
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
|
| 11 |
+
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
|
| 12 |
+
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
|
| 13 |
+
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
|
| 14 |
+
document,'script','//connect.facebook.net/en_US/fbevents.js');
|
| 15 |
+
fbq('init', '<?php echo $pixel; ?>');
|
| 16 |
+
fbq('track', "PageView");
|
| 17 |
+
|
| 18 |
+
<?php if ($cartProduct): ?>
|
| 19 |
+
fbq('track', 'AddToCart', {
|
| 20 |
+
content_type: 'product',
|
| 21 |
+
content_ids: ['<?php echo $cartProduct->id; ?>'],
|
| 22 |
+
value: <?php echo $cartProduct->price; ?>,
|
| 23 |
+
currency: '<?php echo Mage::app()->getStore()->getCurrentCurrencyCode(); ?>',
|
| 24 |
+
product_catalog_id: '<?php echo $catalogId; ?>'
|
| 25 |
+
});
|
| 26 |
+
<?php endif; ?>
|
| 27 |
+
</script>
|
| 28 |
+
<noscript>
|
| 29 |
+
<img height="1" width="1" style="display:none" src="//www.facebook.com/tr?id=<?php echo $fbpixel; ?>&ev=PageView&noscript=1" />
|
| 30 |
+
</noscript>
|
| 31 |
+
<!-- End Facebook Pixel Code -->
|
| 32 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/cartsguru/product/view.phtml
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$facebookEnabled = $this->isFacebookEnabled();
|
| 3 |
+
$pixel = $this->getPixel();
|
| 4 |
+
$catalogId = $this->getCatalogId();
|
| 5 |
+
|
| 6 |
+
if($facebookEnabled && $pixel && $catalogId && Mage::registry('product')):
|
| 7 |
+
$product = Mage::registry('product');
|
| 8 |
+
$price = $product->getData('price');
|
| 9 |
+
if (!$price) {
|
| 10 |
+
$price = $product->getData('special_price');
|
| 11 |
+
}
|
| 12 |
+
$price = number_format((double)$price, 2, '.', '');
|
| 13 |
+
?>
|
| 14 |
+
<script type="text/javascript">
|
| 15 |
+
fbq('track', 'ViewContent', {
|
| 16 |
+
content_type: 'product',
|
| 17 |
+
content_ids: ['<?php echo $product->getId(); ?>'],
|
| 18 |
+
value: <?php echo $price; ?>,
|
| 19 |
+
currency: '<?php echo Mage::app()->getStore()->getCurrentCurrencyCode(); ?>',
|
| 20 |
+
product_catalog_id: '<?php echo $catalogId; ?>'
|
| 21 |
+
});
|
| 22 |
+
</script>
|
| 23 |
+
<?php endif; ?>
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>cartsguru</name>
|
| 4 |
-
<version>1.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/gpl-license.php">GPL</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -16,11 +16,11 @@ Effortlessly reduce the number of abandoned shopping carts by automating telepho
|
|
| 16 |

|
| 17 |
- SMS Callback & Push SMS
|
| 18 |
Send to your prospective customers having abandoned a cart, an SMS suggesting a free call back from your customer relations service, a straightforward SMS reminder or an SMS offering a personalized discount</description>
|
| 19 |
-
<notes>- Added
|
| 20 |
<authors><author><name>Maxime Pruvost</name><user>cgmaximepruvost</user><email>maxime@carts.guru</email></author></authors>
|
| 21 |
-
<date>2016-
|
| 22 |
-
<time>15:
|
| 23 |
-
<contents><target name="magelocal"><dir name="Cartsguru"><dir name="Helper"><file name="Data.php" hash="
|
| 24 |
<compatible/>
|
| 25 |
<dependencies><required><php><min>5.3.0</min><max>7.1.0</max></php></required></dependencies>
|
| 26 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>cartsguru</name>
|
| 4 |
+
<version>1.3.0</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/gpl-license.php">GPL</license>
|
| 7 |
<channel>community</channel>
|
| 16 |

|
| 17 |
- SMS Callback & Push SMS
|
| 18 |
Send to your prospective customers having abandoned a cart, an SMS suggesting a free call back from your customer relations service, a straightforward SMS reminder or an SMS offering a personalized discount</description>
|
| 19 |
+
<notes>- Added Facebook retargeting integration</notes>
|
| 20 |
<authors><author><name>Maxime Pruvost</name><user>cgmaximepruvost</user><email>maxime@carts.guru</email></author></authors>
|
| 21 |
+
<date>2016-12-20</date>
|
| 22 |
+
<time>15:32:15</time>
|
| 23 |
+
<contents><target name="magelocal"><dir name="Cartsguru"><dir name="Block"><file name="Pixel.php" hash="41b3ef3ca05c5341d2c94c99fc8cdd14"/></dir><dir name="Helper"><file name="Data.php" hash="bfdd570b0b1398578bd50354acfaee50"/><file name="Tools.php" hash="e2f56c3387eb0b0650aa5f49f8207618"/></dir><dir name="Model"><file name="Catalog.php" hash="93b42e79b4350978aa6da15e6305835c"/><file name="Observer.php" hash="6fbedb182fee9f8d52d8f86b9608c92a"/><file name="Webservice.php" hash="4dafc50cdc1cc664e69997618569a625"/></dir><dir name="controllers"><file name="AdminController.php" hash="35691c3127363c623e5c0c1a83a5c951"/><file name="CatalogController.php" hash="ce0b4523b20b094f1d0b438f0b8b1d42"/><file name="IndexController.php" hash="21147a5de4f498b13e9f402100a868e9"/><file name="RecovercartController.php" hash="4b0d7b3c0d18f5c451932caee9daac5b"/><file name="SaveaccountController.php" hash="6b490eca17f516a4f95bba9d4c45d30b"/></dir><dir name="etc"><file name="config.xml" hash="e08d9a1c57995818f0688c577062a726"/><file name="system.xml" hash="cb0fbf86d2be47dbd719739ee79c4cba"/></dir><dir name="sql"><dir name="cartsguru_setup"><file name="install-1.0.0.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.0.0-1.0.1.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.0.1-1.0.2.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.0.2-1.1.0.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.1.0-1.1.1.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.1.1-1.1.2.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.1.2-1.1.3.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.1.3-1.1.4 .php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.1.4-1.1.5.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.1.5-1.2.0.php" hash="066c5cfb9870c04737cba2d2edb30a40"/><file name="upgrade-1.2.0-1.2.1.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.2.1-1.2.2.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.2.10-1.2.11.php" hash="84cb92331d31afda4f06aca50dbd597e"/><file name="upgrade-1.2.11-1.2.12.php" hash="84cb92331d31afda4f06aca50dbd597e"/><file name="upgrade-1.2.12-1.2.13.php" hash="84cb92331d31afda4f06aca50dbd597e"/><file name="upgrade-1.2.13-1.2.14.php" hash="84cb92331d31afda4f06aca50dbd597e"/><file name="upgrade-1.2.14-1.2.15.php" hash="c96e44a4737e1d8b0f4915c55a67c048"/><file name="upgrade-1.2.15-1.2.16.php" hash="c96e44a4737e1d8b0f4915c55a67c048"/><file name="upgrade-1.2.16-1.3.0.php" hash="c96e44a4737e1d8b0f4915c55a67c048"/><file name="upgrade-1.2.2-1.2.3.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.2.3-1.2.4.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.2.4-1.2.5.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.2.5-1.2.6.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.2.6-1.2.7.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.2.7-1.2.8.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.2.8-1.2.9.php" hash="381716ae5001678f8bcc6680bad68015"/><file name="upgrade-1.2.9-1.2.10.php" hash="84cb92331d31afda4f06aca50dbd597e"/></dir></dir></dir></target><target name="magelocale"><dir name="fr_FR"><file name="CartsGuru.csv" hash="b6d51893c33ddef1d53372d3a23b036c"/></dir><dir name="en_US"><file name="CartsGuru.csv" hash="921cb4133db47471456759443bb269f5"/></dir></target><target name="mageetc"><dir name="modules"><file name="Cartsguru.xml" hash="32bfa7d63b1a5b6b8f7977bf31af4e28"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="cartsguru.xml" hash="a886b0c3b06fdc08d1602c3f1fa0eff0"/></dir><dir name="template"><dir name="cartsguru"><dir name="checkout"><file name="purchase.phtml" hash="1035c7fed71153aa4c9f5e2d765deb7a"/></dir><file name="pixel.phtml" hash="501f22c8734c63abee6eb985eea05ee6"/><dir name="product"><file name="view.phtml" hash="9ab2487a583615c61e85a96ee0795ad3"/></dir></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="cartsguru"><file name="checkout.js" hash="1be2d62171ffbafe51f66dc1abc1a332"/></dir></dir></target></contents>
|
| 24 |
<compatible/>
|
| 25 |
<dependencies><required><php><min>5.3.0</min><max>7.1.0</max></php></required></dependencies>
|
| 26 |
</package>
|
