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:
parent
92c5988b96
commit
ee271d98c8
@ -37,6 +37,7 @@
|
||||
"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}",
|
||||
"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}",
|
||||
"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},
|
||||
|
@ -632,6 +632,8 @@ function confirmation(idProduct, idCombination, quantity, json) {
|
||||
"id" : idProduct,
|
||||
"variant" : idCombination,
|
||||
"name" : ""+json.products[i].name+"",
|
||||
"brand": ""+json.products[i].category_name+"",
|
||||
"category": ""+json.products[i].category_name+"",
|
||||
"price" : prod_price.trim(),
|
||||
"qty" : quantity
|
||||
};
|
||||
|
@ -146,18 +146,30 @@ if($id_product = (int) Tools::getValue('id_product')) {
|
||||
$combinations[$id_product_attribute]['list'] = $attributeList;
|
||||
}
|
||||
|
||||
|
||||
$smarty->assign(array(
|
||||
'groups' => $groups,
|
||||
'combinaisons' => $combinations, /* Kept for compatibility purpose only */
|
||||
'combinations' => $combinations,
|
||||
'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(
|
||||
'cartex' => Module::isInstalled('blockcartex'),
|
||||
'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),
|
||||
'ecotax_tax_inc' => $ecotaxTaxAmount,
|
||||
'tax_rate' => $tax,
|
||||
|
@ -488,6 +488,7 @@
|
||||
<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="id_product_attribute" id="idCombination" value="" />
|
||||
<input type="hidden" name="category_name" id="category_name" value="{$category_name}" />
|
||||
</p>
|
||||
<h1 class="product_footer_title">{$product->name}</h1>
|
||||
<div class="border-separator"></div>
|
||||
@ -630,6 +631,8 @@
|
||||
"id" : idProduct,
|
||||
"variant" : idAttribute,
|
||||
"name" : ""+$('.product_footer_title').text()+"",
|
||||
"brand" : ""+$('#category_name').val()+"",
|
||||
"category" : ""+$('#category_name').val()+"",
|
||||
"price" : prod_price.trim(),
|
||||
"qty" : quantity
|
||||
};
|
||||
|
@ -218,10 +218,20 @@ class GAnalytics extends Module
|
||||
$products = $order->getProducts();
|
||||
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('
|
||||
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']));
|
||||
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` = '.intval($product['product_id']).'
|
||||
AND cl.`id_lang` = '.intval($parameters['PS_LANG_DEFAULT'])
|
||||
);
|
||||
|
||||
$items[] = array(
|
||||
'OrderId' => intval($order->id), // order ID - required
|
||||
|
@ -32,6 +32,7 @@
|
||||
'id': '{$item.SKU}', // Product ID (string).
|
||||
'name': '{$item.Product}', // Product name (string).
|
||||
'category': '{$item.Category}', // Product category (string).
|
||||
'brand': '{$item.Category}', // Product brand (string).
|
||||
'price': '{$item.Price}', // Product price (currency).
|
||||
'quantity': {$item.Quantity} // Product quantity (number).
|
||||
});
|
||||
|
@ -125,6 +125,17 @@ class Cart extends CartCore {
|
||||
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]);
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
|
@ -199,6 +199,8 @@
|
||||
ga('ec:addProduct', {
|
||||
'id': product.id,
|
||||
'name': product.name,
|
||||
'brand': product.category,
|
||||
'category': product.category,
|
||||
'variant' : product.variant,
|
||||
'price': product.price,
|
||||
'quantity': product.qty
|
||||
@ -206,6 +208,19 @@
|
||||
ga('ec:setAction', 'add');
|
||||
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>
|
||||
{/literal}
|
||||
{elseif $cookie->id_lang == 3}
|
||||
@ -319,6 +334,8 @@
|
||||
ga('ec:addProduct', {
|
||||
'id': product.id,
|
||||
'name': product.name,
|
||||
'brand': product.category,
|
||||
'category': product.category,
|
||||
'variant' : product.variant,
|
||||
'price': product.price,
|
||||
'quantity': product.qty
|
||||
@ -326,6 +343,19 @@
|
||||
ga('ec:setAction', 'add');
|
||||
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>
|
||||
{/literal}
|
||||
{/if}
|
||||
|
@ -68,6 +68,27 @@ function deletProductFromSummary(id)
|
||||
productAttributeId = parseInt(ids[1]);
|
||||
if (typeof(ids[2]) != 'undefined')
|
||||
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({
|
||||
type: 'GET',
|
||||
url: baseDir + 'cart.php',
|
||||
@ -125,6 +146,10 @@ function deletProductFromSummary(id)
|
||||
if (jsonData.carriers != null)
|
||||
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);}
|
||||
@ -156,6 +181,26 @@ function upQuantity(id, qty)
|
||||
productAttributeId = parseInt(ids[1]);
|
||||
if (typeof(ids[2]) != 'undefined')
|
||||
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({
|
||||
type: 'GET',
|
||||
url: baseDir + 'cart.php',
|
||||
@ -183,6 +228,11 @@ function upQuantity(id, qty)
|
||||
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
|
||||
if (jsonData.carriers != null)
|
||||
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);}
|
||||
@ -212,6 +262,25 @@ function downQuantity(id, qty)
|
||||
productAttributeId = parseInt(ids[1]);
|
||||
if (typeof(ids[2]) != 'undefined')
|
||||
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({
|
||||
type: 'GET',
|
||||
url: baseDir + 'cart.php',
|
||||
@ -239,6 +308,10 @@ function downQuantity(id, qty)
|
||||
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
|
||||
if (jsonData.carriers != null)
|
||||
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);}
|
||||
|
@ -36,6 +36,7 @@
|
||||
"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}",
|
||||
"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}",
|
||||
"idCombination": {if isset($product.attributes_small)}{$productAttributeId}{else}0{/if},
|
||||
{if isset($product.attributes_small)}
|
||||
|
@ -24,12 +24,12 @@
|
||||
* 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">
|
||||
<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 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}
|
||||
</td>
|
||||
{*<td class="cart_ref">{if $product.reference}{$product.reference|escape:'htmlall':'UTF-8'}{else}--{/if}</td>*}
|
||||
|
@ -250,7 +250,7 @@
|
||||
{* Then the customized datas ones*}
|
||||
{if isset($customizedDatas.$productId.$productAttributeId)}
|
||||
{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">
|
||||
{foreach from=$customization.datas key='type' item='datas'}
|
||||
{if $type == $CUSTOMIZE_FILE}
|
||||
|
@ -204,12 +204,27 @@
|
||||
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', 'add');
|
||||
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>
|
||||
{/literal}
|
||||
@ -323,12 +338,27 @@
|
||||
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', 'add');
|
||||
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>
|
||||
{/literal}
|
||||
|
@ -68,6 +68,27 @@ function deletProductFromSummary(id)
|
||||
productAttributeId = parseInt(ids[1]);
|
||||
if (typeof(ids[2]) != 'undefined')
|
||||
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({
|
||||
type: 'GET',
|
||||
url: baseDir + 'cart.php',
|
||||
@ -124,6 +145,10 @@ function deletProductFromSummary(id)
|
||||
if (jsonData.carriers != null)
|
||||
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);}
|
||||
@ -144,6 +169,26 @@ function upQuantity(id, qty)
|
||||
productAttributeId = parseInt(ids[1]);
|
||||
if (typeof(ids[2]) != 'undefined')
|
||||
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({
|
||||
type: 'GET',
|
||||
url: baseDir + 'cart.php',
|
||||
@ -171,6 +216,11 @@ function upQuantity(id, qty)
|
||||
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
|
||||
if (jsonData.carriers != null)
|
||||
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);}
|
||||
@ -200,6 +250,26 @@ function downQuantity(id, qty)
|
||||
productAttributeId = parseInt(ids[1]);
|
||||
if (typeof(ids[2]) != 'undefined')
|
||||
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({
|
||||
type: 'GET',
|
||||
url: baseDir + 'cart.php',
|
||||
@ -227,6 +297,10 @@ function downQuantity(id, qty)
|
||||
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
|
||||
if (jsonData.carriers != null)
|
||||
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);}
|
||||
|
@ -36,6 +36,7 @@
|
||||
"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}",
|
||||
"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}",
|
||||
"idCombination": {if isset($product.attributes_small)}{$productAttributeId}{else}0{/if},
|
||||
{if isset($product.attributes_small)}
|
||||
|
@ -24,14 +24,14 @@
|
||||
* 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">
|
||||
<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 class="cart_name">
|
||||
<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>
|
||||
{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>
|
||||
|
Loading…
Reference in New Issue
Block a user