continuation of updating of market data with addition of remove from cart to GA and addition of name of sale when product is sent to GA

This commit is contained in:
Marion Muszynski 2017-03-07 13:25:46 +01:00
parent 92c5988b96
commit ee271d98c8
16 changed files with 272 additions and 23 deletions

View File

@ -1,5 +1,5 @@
{* {*
* 2007-2011 PrestaShop * 2007-2011 PrestaShop
* *
* NOTICE OF LICENSE * NOTICE OF LICENSE
* *
@ -34,9 +34,10 @@
"id": {$product.id_product}, "id": {$product.id_product},
"link": "{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category)|addslashes|replace:'\\\'':'\''}", "link": "{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category)|addslashes|replace:'\\\'':'\''}",
"quantity": {$product.cart_quantity}, "quantity": {$product.cart_quantity},
"id_image": "{$link->getImageLink($product.link_rewrite, $product.id_image, 'mini_carre')|addslashes}", "id_image": "{$link->getImageLink($product.link_rewrite, $product.id_image, 'mini_carre')|addslashes}",
"priceByLine": "{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total}{else}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total_wt}{/if}", "priceByLine": "{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total}{else}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total_wt}{/if}",
"name": "{$product.name|html_entity_decode:2:'UTF-8'|escape|truncate:40:'...':true}", "name": "{$product.name|html_entity_decode:2:'UTF-8'|escape|truncate:40:'...':true}",
"category_name": "{$product.category_name|html_entity_decode:2:'UTF-8'|escape|truncate:16:'...':true}",
"unit_price": "{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.price_wt}", "unit_price": "{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.price_wt}",
"price": "{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total}{else}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total_wt}{/if}", "price": "{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total}{else}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total_wt}{/if}",
"idCombination": {if isset($product.attributes_small)}{$productAttributeId}{else}0{/if}, "idCombination": {if isset($product.attributes_small)}{$productAttributeId}{else}0{/if},

View File

@ -632,6 +632,8 @@ function confirmation(idProduct, idCombination, quantity, json) {
"id" : idProduct, "id" : idProduct,
"variant" : idCombination, "variant" : idCombination,
"name" : ""+json.products[i].name+"", "name" : ""+json.products[i].name+"",
"brand": ""+json.products[i].category_name+"",
"category": ""+json.products[i].category_name+"",
"price" : prod_price.trim(), "price" : prod_price.trim(),
"qty" : quantity "qty" : quantity
}; };

View File

@ -146,18 +146,30 @@ if($id_product = (int) Tools::getValue('id_product')) {
$combinations[$id_product_attribute]['list'] = $attributeList; $combinations[$id_product_attribute]['list'] = $attributeList;
} }
$smarty->assign(array( $smarty->assign(array(
'groups' => $groups, 'groups' => $groups,
'combinaisons' => $combinations, /* Kept for compatibility purpose only */ 'combinaisons' => $combinations, /* Kept for compatibility purpose only */
'combinations' => $combinations, 'combinations' => $combinations,
'colors' => (sizeof($colors) && $product->id_color_default)? $colors: FALSE, 'colors' => (sizeof($colors) && $product->id_color_default)? $colors: FALSE,
'combinationImages' => $combinationImages, 'combinationImages' => $combinationImages
)); ));
} }
$category_name = $category_name = Db::getInstance()->getRow('
SELECT cl.`name`
FROM `'._DB_PREFIX_.'product_ps_cache` ps
LEFT JOIN `'._DB_PREFIX_.'privatesale` s ON (s.`id_sale` = ps.`id_sale`)
LEFT JOIN `'._DB_PREFIX_.'category` c ON (c.`id_category` = s.`id_category`)
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (cl.`id_category` = c.`id_category`)
WHERE ps.`id_product` = '.(int)$id_product.'
AND cl.`id_lang` = '.(int)$cookie->id_lang
);
$smarty->assign(array( $smarty->assign(array(
'cartex' => Module::isInstalled('blockcartex'), 'cartex' => Module::isInstalled('blockcartex'),
'product' => $product, 'product' => $product,
'category_name' => $category_name['name'],
'quantity_discounts' => formatQuantityDiscounts(SpecificPrice::getQuantityDiscounts((int) $product->id, (int) Shop::getCurrentShop(), (int) $cookie->id_currency, $id_country, $id_group), $product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, FALSE), (float) $tax), 'quantity_discounts' => formatQuantityDiscounts(SpecificPrice::getQuantityDiscounts((int) $product->id, (int) Shop::getCurrentShop(), (int) $cookie->id_currency, $id_country, $id_group), $product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, FALSE), (float) $tax),
'ecotax_tax_inc' => $ecotaxTaxAmount, 'ecotax_tax_inc' => $ecotaxTaxAmount,
'tax_rate' => $tax, 'tax_rate' => $tax,

View File

@ -488,6 +488,7 @@
<input type="hidden" name="id_product" value="{$product->id|intval}" id="product_page_product_id" /> <input type="hidden" name="id_product" value="{$product->id|intval}" id="product_page_product_id" />
<input type="hidden" name="add" value="1" /> <input type="hidden" name="add" value="1" />
<input type="hidden" name="id_product_attribute" id="idCombination" value="" /> <input type="hidden" name="id_product_attribute" id="idCombination" value="" />
<input type="hidden" name="category_name" id="category_name" value="{$category_name}" />
</p> </p>
<h1 class="product_footer_title">{$product->name}</h1> <h1 class="product_footer_title">{$product->name}</h1>
<div class="border-separator"></div> <div class="border-separator"></div>
@ -630,6 +631,8 @@
"id" : idProduct, "id" : idProduct,
"variant" : idAttribute, "variant" : idAttribute,
"name" : ""+$('.product_footer_title').text()+"", "name" : ""+$('.product_footer_title').text()+"",
"brand" : ""+$('#category_name').val()+"",
"category" : ""+$('#category_name').val()+"",
"price" : prod_price.trim(), "price" : prod_price.trim(),
"qty" : quantity "qty" : quantity
}; };

View File

@ -218,10 +218,20 @@ class GAnalytics extends Module
$products = $order->getProducts(); $products = $order->getProducts();
foreach ($products AS $product) foreach ($products AS $product)
{ {
// $category = Db::getInstance()->getRow('
// SELECT name FROM `'._DB_PREFIX_.'category_lang` , '._DB_PREFIX_.'product
// WHERE `id_product` = '.intval($product['product_id']).' AND `id_category_default` = `id_category`
// AND `id_lang` = '.intval($parameters['PS_LANG_DEFAULT']));
$category = Db::getInstance()->getRow(' $category = Db::getInstance()->getRow('
SELECT name FROM `'._DB_PREFIX_.'category_lang` , '._DB_PREFIX_.'product SELECT cl.`name`
WHERE `id_product` = '.intval($product['product_id']).' AND `id_category_default` = `id_category` FROM `'._DB_PREFIX_.'product_ps_cache` ps
AND `id_lang` = '.intval($parameters['PS_LANG_DEFAULT'])); LEFT JOIN `'._DB_PREFIX_.'privatesale` s ON (s.`id_sale` = ps.`id_sale`)
LEFT JOIN `'._DB_PREFIX_.'category` c ON (c.`id_category` = s.`id_category`)
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (cl.`id_category` = c.`id_category`)
WHERE ps.`id_product` = '.intval($product['product_id']).'
AND cl.`id_lang` = '.intval($parameters['PS_LANG_DEFAULT'])
);
$items[] = array( $items[] = array(
'OrderId' => intval($order->id), // order ID - required 'OrderId' => intval($order->id), // order ID - required

View File

@ -32,6 +32,7 @@
'id': '{$item.SKU}', // Product ID (string). 'id': '{$item.SKU}', // Product ID (string).
'name': '{$item.Product}', // Product name (string). 'name': '{$item.Product}', // Product name (string).
'category': '{$item.Category}', // Product category (string). 'category': '{$item.Category}', // Product category (string).
'brand': '{$item.Category}', // Product brand (string).
'price': '{$item.Price}', // Product price (currency). 'price': '{$item.Price}', // Product price (currency).
'quantity': {$item.Quantity} // Product quantity (number). 'quantity': {$item.Quantity} // Product quantity (number).
}); });

View File

@ -125,6 +125,17 @@ class Cart extends CartCore {
if (array_key_exists($row['id_product_attribute'].'-'.$this->id_lang, self::$_attributesLists)) if (array_key_exists($row['id_product_attribute'].'-'.$this->id_lang, self::$_attributesLists))
$row = array_merge($row, self::$_attributesLists[$row['id_product_attribute'].'-'.$this->id_lang]); $row = array_merge($row, self::$_attributesLists[$row['id_product_attribute'].'-'.$this->id_lang]);
$category_name = Db::getInstance()->getRow('
SELECT cl.`name`
FROM `'._DB_PREFIX_.'product_ps_cache` ps
LEFT JOIN `'._DB_PREFIX_.'privatesale` s ON (s.`id_sale` = ps.`id_sale`)
LEFT JOIN `'._DB_PREFIX_.'category` c ON (c.`id_category` = s.`id_category`)
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (cl.`id_category` = c.`id_category`)
WHERE ps.`id_product` = '.(int)$row['id_product'].'
AND cl.`id_lang` = '.(int)$this->id_lang
);
$row['category_name'] = $category_name['name'];
$this->_products[] = $row; $this->_products[] = $row;
} }

View File

@ -199,6 +199,8 @@
ga('ec:addProduct', { ga('ec:addProduct', {
'id': product.id, 'id': product.id,
'name': product.name, 'name': product.name,
'brand': product.category,
'category': product.category,
'variant' : product.variant, 'variant' : product.variant,
'price': product.price, 'price': product.price,
'quantity': product.qty 'quantity': product.qty
@ -206,6 +208,19 @@
ga('ec:setAction', 'add'); ga('ec:setAction', 'add');
ga('send', 'event', 'UX', 'click', 'add to cart'); ga('send', 'event', 'UX', 'click', 'add to cart');
} }
function removeFromCartToGA(product) {
ga('ec:addProduct', {
'id': product.id,
'name': product.name,
'brand': product.category,
'category': product.category,
'variant' : product.variant,
'price': product.price,
'quantity': product.qty
});
ga('ec:setAction', 'remove');
ga('send', 'event', 'UX', 'click', 'remove to cart');
}
</script> </script>
{/literal} {/literal}
{elseif $cookie->id_lang == 3} {elseif $cookie->id_lang == 3}
@ -319,6 +334,8 @@
ga('ec:addProduct', { ga('ec:addProduct', {
'id': product.id, 'id': product.id,
'name': product.name, 'name': product.name,
'brand': product.category,
'category': product.category,
'variant' : product.variant, 'variant' : product.variant,
'price': product.price, 'price': product.price,
'quantity': product.qty 'quantity': product.qty
@ -326,6 +343,19 @@
ga('ec:setAction', 'add'); ga('ec:setAction', 'add');
ga('send', 'event', 'UX', 'click', 'add to cart'); ga('send', 'event', 'UX', 'click', 'add to cart');
} }
function removeFromCartToGA(product) {
ga('ec:addProduct', {
'id': product.id,
'name': product.name,
'brand': product.category,
'category': product.category,
'variant' : product.variant,
'price': product.price,
'quantity': product.qty
});
ga('ec:setAction', 'remove');
ga('send', 'event', 'UX', 'click', 'remove to cart');
}
</script> </script>
{/literal} {/literal}
{/if} {/if}

View File

@ -68,6 +68,27 @@ function deletProductFromSummary(id)
productAttributeId = parseInt(ids[1]); productAttributeId = parseInt(ids[1]);
if (typeof(ids[2]) != 'undefined') if (typeof(ids[2]) != 'undefined')
customizationId = parseInt(ids[2]); customizationId = parseInt(ids[2]);
// send to GA
var product_name = $('#product_'+id+' .cart_description a.cart_product_name').text();
var qty = $('#product_'+id+' .cart_quantity input[name="quantity_'+id+'_hidden"]').val();
var category_name = $('#product_'+id).attr('category_name');
if(category_name == null || category_name == "" || category_name == undefined) {
category_name = "";
}
var prod_price = $('#product_price_'+id).text();
prod_price = prod_price.replace(",",".");
prod_price = prod_price.replace("€","");
var productToGA = {
"id" : productId,
"variant" : productAttributeId,
"name" : ""+product_name.trim()+"",
"brand": ""+category_name.trim()+"",
"category": ""+category_name.trim()+"",
"price" : prod_price.trim(),
"qty" : qty
};
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: baseDir + 'cart.php', url: baseDir + 'cart.php',
@ -125,6 +146,10 @@ function deletProductFromSummary(id)
if (jsonData.carriers != null) if (jsonData.carriers != null)
updateCarrierList(jsonData); updateCarrierList(jsonData);
if (window.ga && ga.create){
removeFromCartToGA(productToGA);
}
} }
}, },
error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);} error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);}
@ -156,6 +181,26 @@ function upQuantity(id, qty)
productAttributeId = parseInt(ids[1]); productAttributeId = parseInt(ids[1]);
if (typeof(ids[2]) != 'undefined') if (typeof(ids[2]) != 'undefined')
customizationId = parseInt(ids[2]); customizationId = parseInt(ids[2]);
// send to GA
var product_name = $('#product_'+id+' .cart_description a.cart_product_name').text();
var category_name = $('#product_'+id).attr('category_name');
if(category_name == null || category_name == "" || category_name == undefined) {
category_name = "";
}
var prod_price = $('#product_price_'+id).text();
prod_price = prod_price.replace(",",".");
prod_price = prod_price.replace("€","");
var productToGA = {
"id" : productId,
"variant" : productAttributeId,
"name" : ""+product_name.trim()+"",
"brand": ""+category_name.trim()+"",
"category": ""+category_name.trim()+"",
"price" : prod_price.trim(),
"qty" : qty
};
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: baseDir + 'cart.php', url: baseDir + 'cart.php',
@ -183,6 +228,11 @@ function upQuantity(id, qty)
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA); updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
if (jsonData.carriers != null) if (jsonData.carriers != null)
updateCarrierList(jsonData); updateCarrierList(jsonData);
// send add product to cart information to GA
if (window.ga && ga.create){
addToCartToGA(productToGA);
}
} }
}, },
error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);} error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);}
@ -212,6 +262,25 @@ function downQuantity(id, qty)
productAttributeId = parseInt(ids[1]); productAttributeId = parseInt(ids[1]);
if (typeof(ids[2]) != 'undefined') if (typeof(ids[2]) != 'undefined')
customizationId = parseInt(ids[2]); customizationId = parseInt(ids[2]);
// send to GA
var product_name = $('#product_'+id+' .cart_description a.cart_product_name').text();
var category_name = $('#product_'+id).attr('category_name');
if(category_name == null || category_name == "" || category_name == undefined) {
category_name = "";
}
var prod_price = $('#product_price_'+id).text();
prod_price = prod_price.replace(",",".");
prod_price = prod_price.replace("€","");
var productToGA = {
"id" : productId,
"variant" : productAttributeId,
"name" : ""+product_name.trim()+"",
"brand": ""+category_name.trim()+"",
"category": ""+category_name.trim()+"",
"price" : prod_price.trim(),
"qty" : qty
};
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: baseDir + 'cart.php', url: baseDir + 'cart.php',
@ -239,6 +308,10 @@ function downQuantity(id, qty)
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA); updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
if (jsonData.carriers != null) if (jsonData.carriers != null)
updateCarrierList(jsonData); updateCarrierList(jsonData);
// send add product to cart information to GA
if (window.ga && ga.create){
removeFromCartToGA(productToGA);
}
} }
}, },
error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);} error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);}

View File

@ -36,6 +36,7 @@
"quantity": {$product.cart_quantity}, "quantity": {$product.cart_quantity},
"priceByLine": "{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total}{else}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total_wt}{/if}", "priceByLine": "{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total}{else}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total_wt}{/if}",
"name": "{$product.name|html_entity_decode:2:'UTF-8'|escape|truncate:16:'...':true}", "name": "{$product.name|html_entity_decode:2:'UTF-8'|escape|truncate:16:'...':true}",
"category_name": "{$product.category_name|html_entity_decode:2:'UTF-8'|escape|truncate:16:'...':true}",
"price": "{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total}{else}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total_wt}{/if}", "price": "{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total}{else}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total_wt}{/if}",
"idCombination": {if isset($product.attributes_small)}{$productAttributeId}{else}0{/if}, "idCombination": {if isset($product.attributes_small)}{$productAttributeId}{else}0{/if},
{if isset($product.attributes_small)} {if isset($product.attributes_small)}

View File

@ -24,12 +24,12 @@
* International Registered Trademark & Property of PrestaShop SA * International Registered Trademark & Property of PrestaShop SA
*} *}
<tr id="product_{$product.id_product}_{$product.id_product_attribute}" class="{if $smarty.foreach.productLoop.last}last_item{elseif $smarty.foreach.productLoop.first}first_item{/if}{if isset($customizedDatas.$productId.$productAttributeId) AND $quantityDisplayed == 0}alternate_item{/if} cart_item"> <tr id="product_{$product.id_product}_{$product.id_product_attribute}" {if isset($product.category_name)}category_name="{$product.category_name}"{/if} class="{if $smarty.foreach.productLoop.last}last_item{elseif $smarty.foreach.productLoop.first}first_item{/if}{if isset($customizedDatas.$productId.$productAttributeId) AND $quantityDisplayed == 0}alternate_item{/if} cart_item">
<td class="cart_product"> <td class="cart_product">
<a href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category)|escape:'htmlall':'UTF-8'}"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'small')}" alt="{$product.name|escape:'htmlall':'UTF-8'}" {if isset($smallSize)}width="{$smallSize.width}" height="{$smallSize.height}" {/if} /></a> <a href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category)|escape:'htmlall':'UTF-8'}"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'small')}" alt="{$product.name|escape:'htmlall':'UTF-8'}" {if isset($smallSize)}width="{$smallSize.width}" height="{$smallSize.height}" {/if} /></a>
</td> </td>
<td class="cart_description"> <td class="cart_description">
<h5><a href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category)|escape:'htmlall':'UTF-8'}">{$product.name|escape:'htmlall':'UTF-8'}</a></h5> <h5><a class="cart_product_name" href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category)|escape:'htmlall':'UTF-8'}">{$product.name|escape:'htmlall':'UTF-8'}</a></h5>
{if isset($product.attributes) && $product.attributes}<a href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category)|escape:'htmlall':'UTF-8'}">{$product.attributes|escape:'htmlall':'UTF-8'}</a>{/if} {if isset($product.attributes) && $product.attributes}<a href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category)|escape:'htmlall':'UTF-8'}">{$product.attributes|escape:'htmlall':'UTF-8'}</a>{/if}
</td> </td>
{*<td class="cart_ref">{if $product.reference}{$product.reference|escape:'htmlall':'UTF-8'}{else}--{/if}</td>*} {*<td class="cart_ref">{if $product.reference}{$product.reference|escape:'htmlall':'UTF-8'}{else}--{/if}</td>*}

View File

@ -250,7 +250,7 @@
{* Then the customized datas ones*} {* Then the customized datas ones*}
{if isset($customizedDatas.$productId.$productAttributeId)} {if isset($customizedDatas.$productId.$productAttributeId)}
{foreach from=$customizedDatas.$productId.$productAttributeId key='id_customization' item='customization'} {foreach from=$customizedDatas.$productId.$productAttributeId key='id_customization' item='customization'}
<tr id="product_{$product.id_product}_{$product.id_product_attribute}_{$id_customization}" class="alternate_item cart_item"> <tr id="product_{$product.id_product}_{$product.id_product_attribute}_{$id_customization}" {if isset($product.category_name)}category_name="{$product.category_name}"{/if} class="alternate_item cart_item">
<td colspan="3"> <td colspan="3">
{foreach from=$customization.datas key='type' item='datas'} {foreach from=$customization.datas key='type' item='datas'}
{if $type == $CUSTOMIZE_FILE} {if $type == $CUSTOMIZE_FILE}
@ -349,7 +349,7 @@
</form> </form>
</div> </div>
{/if} {/if}
{if $economy > 0} {if $economy > 0}
<p class="economy">{l s='savings'} <span class="economy-price">{displayPrice price=$economy}</span><span class="economy-currency"></span> ({displayPrice price=$total_products_wt} {l s='instead of'} {displayPrice price=$strike_price})</p> <p class="economy">{l s='savings'} <span class="economy-price">{displayPrice price=$economy}</span><span class="economy-currency"></span> ({displayPrice price=$total_products_wt} {l s='instead of'} {displayPrice price=$strike_price})</p>
{/if} {/if}
<p class="shipping-calculate">{l s='Shipping calculated its step 3'}</p> <p class="shipping-calculate">{l s='Shipping calculated its step 3'}</p>
@ -424,7 +424,7 @@
{/if}*} {/if}*}
<!-- <!--
<p style="margin-top: 15px; color:#222; margin-bottom:0px "> <p style="margin-top: 15px; color:#222; margin-bottom:0px ">
<img src="http://static2.bebeboutik.com/img/delay/noel_site_{$cookie->id_lang}.png" alt="" style="float:left; margin: 0 10px 10px 0 "> <img src="http://static2.bebeboutik.com/img/delay/noel_site_{$cookie->id_lang}.png" alt="" style="float:left; margin: 0 10px 10px 0 ">
<span style="top:6px; position: relative"> <span style="top:6px; position: relative">

View File

@ -204,12 +204,27 @@
ga('ec:addProduct', { ga('ec:addProduct', {
'id': product.id, 'id': product.id,
'name': product.name, 'name': product.name,
'brand': product.category,
'category': product.category,
'variant' : product.variant, 'variant' : product.variant,
'price': product.price, 'price': product.price,
'quantity': product.qty 'quantity': product.qty
}); });
ga('ec:setAction', 'add'); ga('ec:setAction', 'add');
ga('send', 'event', 'UX', 'click', 'add to cart'); ga('send', 'event', 'UX', 'click', 'add to cart');
}
function removeFromCartToGA(product) {
ga('ec:addProduct', {
'id': product.id,
'name': product.name,
'brand': product.category,
'category': product.category,
'variant' : product.variant,
'price': product.price,
'quantity': product.qty
});
ga('ec:setAction', 'remove');
ga('send', 'event', 'UX', 'click', 'remove to cart');
} }
</script> </script>
{/literal} {/literal}
@ -323,12 +338,27 @@
ga('ec:addProduct', { ga('ec:addProduct', {
'id': product.id, 'id': product.id,
'name': product.name, 'name': product.name,
'brand': product.category,
'category': product.category,
'variant' : product.variant, 'variant' : product.variant,
'price': product.price, 'price': product.price,
'quantity': product.qty 'quantity': product.qty
}); });
ga('ec:setAction', 'add'); ga('ec:setAction', 'add');
ga('send', 'event', 'UX', 'click', 'add to cart'); ga('send', 'event', 'UX', 'click', 'add to cart');
}
function removeFromCartToGA(product) {
ga('ec:addProduct', {
'id': product.id,
'name': product.name,
'brand': product.category,
'category': product.category,
'variant' : product.variant,
'price': product.price,
'quantity': product.qty
});
ga('ec:setAction', 'remove');
ga('send', 'event', 'UX', 'click', 'remove to cart');
} }
</script> </script>
{/literal} {/literal}

View File

@ -68,6 +68,27 @@ function deletProductFromSummary(id)
productAttributeId = parseInt(ids[1]); productAttributeId = parseInt(ids[1]);
if (typeof(ids[2]) != 'undefined') if (typeof(ids[2]) != 'undefined')
customizationId = parseInt(ids[2]); customizationId = parseInt(ids[2]);
// send to GA
var product_name = $('#product_'+id+' .cart_name a.cart_product_name').text();
var qty = $('#product_'+id+' .cart_quantity input[name="quantity_'+id+'_hidden"]').val();
var category_name = $('#product_'+id).attr('category_name');
if(category_name == null || category_name == "" || category_name == undefined) {
category_name = "";
}
var prod_price = $('#product_price_'+id).text();
prod_price = prod_price.replace(",",".");
prod_price = prod_price.replace("€","");
var productToGA = {
"id" : productId,
"variant" : productAttributeId,
"name" : ""+product_name.trim()+"",
"brand": ""+category_name.trim()+"",
"category": ""+category_name.trim()+"",
"price" : prod_price.trim(),
"qty" : qty
};
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: baseDir + 'cart.php', url: baseDir + 'cart.php',
@ -124,6 +145,10 @@ function deletProductFromSummary(id)
if (jsonData.carriers != null) if (jsonData.carriers != null)
updateCarrierList(jsonData); updateCarrierList(jsonData);
if (window.ga && ga.create){
removeFromCartToGA(productToGA);
}
} }
}, },
error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);} error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);}
@ -144,6 +169,26 @@ function upQuantity(id, qty)
productAttributeId = parseInt(ids[1]); productAttributeId = parseInt(ids[1]);
if (typeof(ids[2]) != 'undefined') if (typeof(ids[2]) != 'undefined')
customizationId = parseInt(ids[2]); customizationId = parseInt(ids[2]);
// send to GA
var product_name = $('#product_'+id+' .cart_name a.cart_product_name').text();
var category_name = $('#product_'+id).attr('category_name');
if(category_name == null || category_name == "" || category_name == undefined) {
category_name = "";
}
var prod_price = $('#product_price_'+id).text();
prod_price = prod_price.replace(",",".");
prod_price = prod_price.replace("€","");
var productToGA = {
"id" : productId,
"variant" : productAttributeId,
"name" : ""+product_name.trim()+"",
"brand": ""+category_name.trim()+"",
"category": ""+category_name.trim()+"",
"price" : prod_price.trim(),
"qty" : qty
};
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: baseDir + 'cart.php', url: baseDir + 'cart.php',
@ -165,12 +210,17 @@ function upQuantity(id, qty)
} }
else else
{ {
updateCustomizedDatas(jsonData.customizedDatas); updateCustomizedDatas(jsonData.customizedDatas);
updateCartSummary(jsonData.summary); updateCartSummary(jsonData.summary);
updateHookShoppingCart(jsonData.HOOK_SHOPPING_CART); updateHookShoppingCart(jsonData.HOOK_SHOPPING_CART);
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA); updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
if (jsonData.carriers != null) if (jsonData.carriers != null)
updateCarrierList(jsonData); updateCarrierList(jsonData);
// send add product to cart information to GA
if (window.ga && ga.create){
addToCartToGA(productToGA);
}
} }
}, },
error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);} error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);}
@ -200,6 +250,26 @@ function downQuantity(id, qty)
productAttributeId = parseInt(ids[1]); productAttributeId = parseInt(ids[1]);
if (typeof(ids[2]) != 'undefined') if (typeof(ids[2]) != 'undefined')
customizationId = parseInt(ids[2]); customizationId = parseInt(ids[2]);
// send to GA
var product_name = $('#product_'+id+' .cart_name a.cart_product_name').text();
var category_name = $('#product_'+id).attr('category_name');
if(category_name == null || category_name == "" || category_name == undefined) {
category_name = "";
}
var prod_price = $('#product_price_'+id).text();
prod_price = prod_price.replace(",",".");
prod_price = prod_price.replace("€","");
var productToGA = {
"id" : productId,
"variant" : productAttributeId,
"name" : ""+product_name.trim()+"",
"brand": ""+category_name.trim()+"",
"category": ""+category_name.trim()+"",
"price" : prod_price.trim(),
"qty" : qty
};
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: baseDir + 'cart.php', url: baseDir + 'cart.php',
@ -227,6 +297,10 @@ function downQuantity(id, qty)
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA); updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
if (jsonData.carriers != null) if (jsonData.carriers != null)
updateCarrierList(jsonData); updateCarrierList(jsonData);
if (window.ga && ga.create){
removeFromCartToGA(productToGA);
}
} }
}, },
error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);} error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);}

View File

@ -36,6 +36,7 @@
"quantity": {$product.cart_quantity}, "quantity": {$product.cart_quantity},
"priceByLine": "{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total}{else}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total_wt}{/if}", "priceByLine": "{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total}{else}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total_wt}{/if}",
"name": "{$product.name|html_entity_decode:2:'UTF-8'|escape|truncate:16:'...':true}", "name": "{$product.name|html_entity_decode:2:'UTF-8'|escape|truncate:16:'...':true}",
"category_name": "{$product.category_name|html_entity_decode:2:'UTF-8'|escape|truncate:16:'...':true}",
"price": "{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total}{else}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total_wt}{/if}", "price": "{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total}{else}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total_wt}{/if}",
"idCombination": {if isset($product.attributes_small)}{$productAttributeId}{else}0{/if}, "idCombination": {if isset($product.attributes_small)}{$productAttributeId}{else}0{/if},
{if isset($product.attributes_small)} {if isset($product.attributes_small)}

View File

@ -24,14 +24,14 @@
* International Registered Trademark & Property of PrestaShop SA * International Registered Trademark & Property of PrestaShop SA
*} *}
<tr id="product_{$product.id_product}_{$product.id_product_attribute}" class="{if $smarty.foreach.productLoop.last}last_item{elseif $smarty.foreach.productLoop.first}first_item{/if}{if isset($customizedDatas.$productId.$productAttributeId) AND $quantityDisplayed == 0}alternate_item{/if} cart_item"> <tr id="product_{$product.id_product}_{$product.id_product_attribute}" {if isset($product.category_name)}category_name="{$product.category_name}"{/if} class="{if $smarty.foreach.productLoop.last}last_item{elseif $smarty.foreach.productLoop.first}first_item{/if}{if isset($customizedDatas.$productId.$productAttributeId) AND $quantityDisplayed == 0}alternate_item{/if} cart_item">
<td class="cart_product"> <td class="cart_product">
<a href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category)|escape:'htmlall':'UTF-8'}"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'large')}" alt="{$product.name|escape:'htmlall':'UTF-8'}" width="70" /></a> <a href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category)|escape:'htmlall':'UTF-8'}"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'large')}" alt="{$product.name|escape:'htmlall':'UTF-8'}" width="70" /></a>
</td> </td>
<td class="cart_name"> <td class="cart_name">
<h5> <h5>
<a href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category)|escape:'htmlall':'UTF-8'}">{$product.name|escape:'htmlall':'UTF-8'|truncate:35:'...'}</a> <a class="cart_product_name" href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category)|escape:'htmlall':'UTF-8'}">{$product.name|escape:'htmlall':'UTF-8'|truncate:35:'...'}</a>
</h5> </h5>
{if isset($product.attributes) && $product.attributes} {if isset($product.attributes) && $product.attributes}
<a href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category)|escape:'htmlall':'UTF-8'}">{$product.attributes|escape:'htmlall':'UTF-8'}</a> <a href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category)|escape:'htmlall':'UTF-8'}">{$product.attributes|escape:'htmlall':'UTF-8'}</a>
@ -53,7 +53,7 @@
{/if} {/if}
{if !isset($customizedDatas.$productId.$productAttributeId) OR $quantityDisplayed > 0} {if !isset($customizedDatas.$productId.$productAttributeId) OR $quantityDisplayed > 0}
<input type="hidden" value="{if $quantityDisplayed == 0 AND isset($customizedDatas.$productId.$productAttributeId)}{$customizedDatas.$productId.$productAttributeId|@count}{else}{$product.cart_quantity-$quantityDisplayed}{/if}" name="quantity_{$product.id_product}_{$product.id_product_attribute}_hidden" /> <input type="hidden" value="{if $quantityDisplayed == 0 AND isset($customizedDatas.$productId.$productAttributeId)}{$customizedDatas.$productId.$productAttributeId|@count}{else}{$product.cart_quantity-$quantityDisplayed}{/if}" name="quantity_{$product.id_product}_{$product.id_product_attribute}_hidden" />
<input size="2" maxlength="3" type="text" class="cart_quantity_input" value="{if $quantityDisplayed == 0 AND isset($customizedDatas.$productId.$productAttributeId)}{$customizedDatas.$productId.$productAttributeId|@count}{else}{$product.cart_quantity-$quantityDisplayed}{/if}" name="quantity_{$product.id_product}_{$product.id_product_attribute}" /> <input size="2" maxlength="3" type="text" class="cart_quantity_input" value="{if $quantityDisplayed == 0 AND isset($customizedDatas.$productId.$productAttributeId)}{$customizedDatas.$productId.$productAttributeId|@count}{else}{$product.cart_quantity-$quantityDisplayed}{/if}" name="quantity_{$product.id_product}_{$product.id_product_attribute}" />
{/if} {/if}
</div> </div>
</div> </div>
@ -63,7 +63,7 @@
<a rel="nofollow" class="cart_quantity_delete" id="{$product.id_product}_{$product.id_product_attribute}" href="{$link->getPageLink('cart.php', true)}?delete&amp;id_product={$product.id_product|intval}&amp;ipa={$product.id_product_attribute|intval}&amp;token={$token_cart}" title="{l s='Delete'}">X</a> <a rel="nofollow" class="cart_quantity_delete" id="{$product.id_product}_{$product.id_product_attribute}" href="{$link->getPageLink('cart.php', true)}?delete&amp;id_product={$product.id_product|intval}&amp;ipa={$product.id_product_attribute|intval}&amp;token={$token_cart}" title="{l s='Delete'}">X</a>
</div> </div>
</td> </td>
<td class="cart_description"> <td class="cart_description">
{*<div class="desc_content"> {*<div class="desc_content">
<h5><a href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category)|escape:'htmlall':'UTF-8'}">{$product.name|escape:'htmlall':'UTF-8'}</a></h5> <h5><a href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category)|escape:'htmlall':'UTF-8'}">{$product.name|escape:'htmlall':'UTF-8'}</a></h5>
@ -79,7 +79,7 @@
{/if} {/if}
{if !isset($customizedDatas.$productId.$productAttributeId) OR $quantityDisplayed > 0} {if !isset($customizedDatas.$productId.$productAttributeId) OR $quantityDisplayed > 0}
<input type="hidden" value="{if $quantityDisplayed == 0 AND isset($customizedDatas.$productId.$productAttributeId)}{$customizedDatas.$productId.$productAttributeId|@count}{else}{$product.cart_quantity-$quantityDisplayed}{/if}" name="quantity_{$product.id_product}_{$product.id_product_attribute}_hidden" /> <input type="hidden" value="{if $quantityDisplayed == 0 AND isset($customizedDatas.$productId.$productAttributeId)}{$customizedDatas.$productId.$productAttributeId|@count}{else}{$product.cart_quantity-$quantityDisplayed}{/if}" name="quantity_{$product.id_product}_{$product.id_product_attribute}_hidden" />
<input size="2" maxlength="3" type="text" class="cart_quantity_input" value="{if $quantityDisplayed == 0 AND isset($customizedDatas.$productId.$productAttributeId)}{$customizedDatas.$productId.$productAttributeId|@count}{else}{$product.cart_quantity-$quantityDisplayed}{/if}" name="quantity_{$product.id_product}_{$product.id_product_attribute}" /> <input size="2" maxlength="3" type="text" class="cart_quantity_input" value="{if $quantityDisplayed == 0 AND isset($customizedDatas.$productId.$productAttributeId)}{$customizedDatas.$productId.$productAttributeId|@count}{else}{$product.cart_quantity-$quantityDisplayed}{/if}" name="quantity_{$product.id_product}_{$product.id_product_attribute}" />
{/if} {/if}
</div> </div>
<div class="gradient"> <div class="gradient">