Merge branch 'ticket-GAnalytics' into develop
This commit is contained in:
commit
338da7eb3f
@ -220,7 +220,7 @@ var ajaxCart = {
|
|||||||
ajaxCart.updateCartInformation(jsonData, addedFromProductPage);
|
ajaxCart.updateCartInformation(jsonData, addedFromProductPage);
|
||||||
|
|
||||||
if(!jsonData.errors) {
|
if(!jsonData.errors) {
|
||||||
confirmation(idProduct, idCombination, quantity);
|
confirmation(idProduct, idCombination, quantity, jsonData);
|
||||||
} else if (jsonData.popup_error_cart){
|
} else if (jsonData.popup_error_cart){
|
||||||
cannotAdd(idProduct, idCombination, quantity, jsonData.errors[0]);
|
cannotAdd(idProduct, idCombination, quantity, jsonData.errors[0]);
|
||||||
}
|
}
|
||||||
@ -411,7 +411,7 @@ var ajaxCart = {
|
|||||||
if (this.id != undefined)
|
if (this.id != undefined)
|
||||||
{
|
{
|
||||||
//create a container for listing the products and hide the 'no product in the cart' message (only if the cart was empty)
|
//create a container for listing the products and hide the 'no product in the cart' message (only if the cart was empty)
|
||||||
if ($('div#cart_block dl.products').length == 0)
|
if ($('div#cart_block dl.products').length == 0)
|
||||||
$('p#cart_block_no_products').hide('fast', 0, function(){
|
$('p#cart_block_no_products').hide('fast', 0, function(){
|
||||||
}).before('<dl class="products"></dl>');
|
}).before('<dl class="products"></dl>');
|
||||||
|
|
||||||
@ -420,7 +420,7 @@ var ajaxCart = {
|
|||||||
var domIdProductAttribute = this.id + '_' + (this.idCombination ? this.idCombination : '0');
|
var domIdProductAttribute = this.id + '_' + (this.idCombination ? this.idCombination : '0');
|
||||||
if($('#cart_block dt#cart_block_product_'+ domIdProduct ).length == 0)
|
if($('#cart_block dt#cart_block_product_'+ domIdProduct ).length == 0)
|
||||||
{
|
{
|
||||||
var productId = parseInt(this.id);
|
var productId = parseInt(this.id);
|
||||||
var productAttributeId = (this.hasAttributes ? parseInt(this.attributes) : 0);
|
var productAttributeId = (this.hasAttributes ? parseInt(this.attributes) : 0);
|
||||||
var name = (this.name.length > 40 ? this.name.substring(0, 10) + '...' : this.name);
|
var name = (this.name.length > 40 ? this.name.substring(0, 10) + '...' : this.name);
|
||||||
var content = '<dt class="hidden" id="cart_block_product_' + domIdProduct + '">';
|
var content = '<dt class="hidden" id="cart_block_product_' + domIdProduct + '">';
|
||||||
@ -619,20 +619,38 @@ var ajaxCart = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function confirmation(idProduct, idCombination, quantity) {
|
function confirmation(idProduct, idCombination, quantity, json) {
|
||||||
top.document.ajaxCart.refresh();
|
top.document.ajaxCart.refresh();
|
||||||
|
|
||||||
|
// send add product to cart information to GA
|
||||||
|
for (i=0;i < json.products.length; i++) {
|
||||||
|
if (json.products[i].id == idProduct) {
|
||||||
|
var prod_price = json.products[i].unit_price;
|
||||||
|
prod_price = prod_price.replace(",",".");
|
||||||
|
prod_price = prod_price.replace("€","");
|
||||||
|
productToGA = {
|
||||||
|
"id" : idProduct,
|
||||||
|
"variant" : idCombination,
|
||||||
|
"name" : ""+json.products[i].name+"",
|
||||||
|
"price" : prod_price.trim(),
|
||||||
|
"qty" : quantity
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// AJOUT PANIER PAGE PRODUIT
|
// AJOUT PANIER PAGE PRODUIT
|
||||||
if($('#quantity_sel').length > 0){
|
if($('#quantity_sel').length > 0){
|
||||||
$('#quantity_sel').html(quantity);
|
$('#quantity_sel').html(quantity);
|
||||||
if(quantity > 1){
|
if(quantity > 1){
|
||||||
var price = $('#price_add_to_cart').html();
|
var price = $('#price_add_to_cart').html();
|
||||||
var price_float = price.replace(",", ".");
|
var price_float = price.replace(",", ".");
|
||||||
var new_price = parseFloat(price_float) * quantity;
|
var new_price = parseFloat(price_float) * quantity;
|
||||||
$('#price_add_to_cart').html(new_price);
|
$('#price_add_to_cart').html(new_price);
|
||||||
}
|
}
|
||||||
$('.overlay_bbb').fadeIn();
|
$('.overlay_bbb').fadeIn();
|
||||||
$('.box_add_to_cart').fadeIn();
|
$('.box_add_to_cart').fadeIn();
|
||||||
|
// send add product to cart information to GA
|
||||||
|
addToCartToGA(productToGA);
|
||||||
}
|
}
|
||||||
// AJOUT PANIER ACHAT EXPRESS
|
// AJOUT PANIER ACHAT EXPRESS
|
||||||
else{
|
else{
|
||||||
@ -647,6 +665,8 @@ function confirmation(idProduct, idCombination, quantity) {
|
|||||||
window.parent.jQuery('body').append(jsonData);
|
window.parent.jQuery('body').append(jsonData);
|
||||||
window.parent.$('.overlay_bbb').fadeIn();
|
window.parent.$('.overlay_bbb').fadeIn();
|
||||||
window.parent.$('.box_add_to_cart').fadeIn();
|
window.parent.$('.box_add_to_cart').fadeIn();
|
||||||
|
// send add product to cart information to GA
|
||||||
|
window.parent.addToCartToGA(productToGA);
|
||||||
},
|
},
|
||||||
error: function() {alert('ERROR: unable to delete the product');}
|
error: function() {alert('ERROR: unable to delete the product');}
|
||||||
});
|
});
|
||||||
@ -656,20 +676,20 @@ function confirmation(idProduct, idCombination, quantity) {
|
|||||||
|
|
||||||
function cannotAdd(idProduct, idCombination, quantity, error_text){
|
function cannotAdd(idProduct, idCombination, quantity, error_text){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: baseDir + 'modules/blockcartex/ajax.php',
|
url: baseDir + 'modules/blockcartex/ajax.php',
|
||||||
async: true,
|
async: true,
|
||||||
cache: false,
|
cache: false,
|
||||||
dataType : "html",
|
dataType : "html",
|
||||||
data: 'id_product=' + idProduct +'&idCombination='+ idCombination +'&quantity='+quantity,
|
data: 'id_product=' + idProduct +'&idCombination='+ idCombination +'&quantity='+quantity,
|
||||||
success: function(jsonData) {
|
success: function(jsonData) {
|
||||||
window.parent.jQuery('body').append(jsonData);
|
window.parent.jQuery('body').append(jsonData);
|
||||||
window.parent.$('#box_error_cart_text').text(error_text);
|
window.parent.$('#box_error_cart_text').text(error_text);
|
||||||
window.parent.$('.overlay_bbb').fadeIn();
|
window.parent.$('.overlay_bbb').fadeIn();
|
||||||
window.parent.$('#box_error_cart').fadeIn();
|
window.parent.$('#box_error_cart').fadeIn();
|
||||||
},
|
},
|
||||||
error: function() {alert('ERROR: unable to delete the product');}
|
error: function() {alert('ERROR: unable to delete the product');}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeAllCart() {
|
function removeAllCart() {
|
||||||
|
@ -90,7 +90,7 @@
|
|||||||
float: left;
|
float: left;
|
||||||
}
|
}
|
||||||
#quantity_wanted_p {
|
#quantity_wanted_p {
|
||||||
padding:0;
|
padding:0;
|
||||||
}
|
}
|
||||||
#quantity_wanted {
|
#quantity_wanted {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
@ -489,7 +489,7 @@
|
|||||||
<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="" />
|
||||||
</p>
|
</p>
|
||||||
<h1>{$product->name}</h1>
|
<h1 class="product_footer_title">{$product->name}</h1>
|
||||||
<div class="border-separator"></div>
|
<div class="border-separator"></div>
|
||||||
<div class="border-separator"></div>
|
<div class="border-separator"></div>
|
||||||
<div class="center_element">
|
<div class="center_element">
|
||||||
@ -606,6 +606,7 @@
|
|||||||
var idProduct = $('#buy_block_footer input[name="id_product"]').val();
|
var idProduct = $('#buy_block_footer input[name="id_product"]').val();
|
||||||
var idAttribute = $('#buy_block_footer input[name="id_product_attribute"]').val();
|
var idAttribute = $('#buy_block_footer input[name="id_product_attribute"]').val();
|
||||||
var quantity = $('#buy_block_footer #quantity_wanted').val();
|
var quantity = $('#buy_block_footer #quantity_wanted').val();
|
||||||
|
|
||||||
if ($(this).attr('disabled') != 'disabled' && $('#buy_block_footer #quantity_wanted:visible').length > 0){
|
if ($(this).attr('disabled') != 'disabled' && $('#buy_block_footer #quantity_wanted:visible').length > 0){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
@ -620,6 +621,20 @@
|
|||||||
if (jsonData.hasError !== true) {
|
if (jsonData.hasError !== true) {
|
||||||
window.parent.$('.ajax_add_to_cart_product_footer_button').removeClass('active');
|
window.parent.$('.ajax_add_to_cart_product_footer_button').removeClass('active');
|
||||||
window.parent.$('a.close_popup_footer').remove();
|
window.parent.$('a.close_popup_footer').remove();
|
||||||
|
|
||||||
|
// send add to cart information to GA
|
||||||
|
var prod_price = $('#our_price_display').text();
|
||||||
|
prod_price = prod_price.replace(",",".");
|
||||||
|
prod_price = prod_price.replace("€","");
|
||||||
|
productToGA = {
|
||||||
|
"id" : idProduct,
|
||||||
|
"variant" : idAttribute,
|
||||||
|
"name" : ""+$('.product_footer_title').text()+"",
|
||||||
|
"price" : prod_price.trim(),
|
||||||
|
"qty" : quantity
|
||||||
|
};
|
||||||
|
window.parent.addToCartToGA(productToGA);
|
||||||
|
|
||||||
$('.product_added_to_cart').show();
|
$('.product_added_to_cart').show();
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$('.product_added_to_cart').hide();
|
$('.product_added_to_cart').hide();
|
||||||
|
@ -86,7 +86,20 @@
|
|||||||
|
|
||||||
ga('create', 'UA-30665119-1', 'auto');
|
ga('create', 'UA-30665119-1', 'auto');
|
||||||
|
|
||||||
{/literal}{if isset($page_name) && $page_name == 'order'}{literal}
|
{/literal}{if isset($page_name) && $page_name == 'category'}{literal}
|
||||||
|
ga('require', 'ec');
|
||||||
|
|
||||||
|
{/literal}{else if isset($page_name) && $page_name == 'product'}{literal}
|
||||||
|
ga('require', 'ec');
|
||||||
|
ga('ec:addProduct', {
|
||||||
|
'id': {/literal}{$product->id}{literal},
|
||||||
|
'name': "{/literal}{$product->name|escape:'htmlall':'UTF-8'}{literal}",
|
||||||
|
'category': "{/literal}{$sale->title[$cookie->id_lang]}{literal}"
|
||||||
|
});
|
||||||
|
|
||||||
|
ga('ec:setAction', 'detail');
|
||||||
|
|
||||||
|
{/literal}{else if isset($page_name) && $page_name == 'order'}{literal}
|
||||||
ga('require', 'ec');
|
ga('require', 'ec');
|
||||||
|
|
||||||
{/literal}
|
{/literal}
|
||||||
@ -154,6 +167,17 @@
|
|||||||
ga('send', 'event', 'Checkout', 'Option', {});
|
ga('send', 'event', 'Checkout', 'Option', {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function addToCartToGA(product) {
|
||||||
|
ga('ec:addProduct', {
|
||||||
|
'id': product.id,
|
||||||
|
'name': product.name,
|
||||||
|
'variant' : product.variant,
|
||||||
|
'price': product.price,
|
||||||
|
'quantity': product.qty
|
||||||
|
});
|
||||||
|
ga('ec:setAction', 'add');
|
||||||
|
ga('send', 'event', 'UX', 'click', 'add to cart');
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
{/literal}
|
{/literal}
|
||||||
{elseif $cookie->id_lang == 3}
|
{elseif $cookie->id_lang == 3}
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
|
|
||||||
var msg = "{l s='You must agree to the terms of service before continuing.' js=1}";
|
var msg = "{l s='You must agree to the terms of service before continuing.' js=1}";
|
||||||
{literal}
|
{literal}
|
||||||
|
// Function to submit carrier and send the information to GA
|
||||||
function submitCarrier() {
|
function submitCarrier() {
|
||||||
var cgv = acceptCGV();
|
var cgv = acceptCGV();
|
||||||
if(cgv) {
|
if(cgv) {
|
||||||
|
@ -34,13 +34,15 @@
|
|||||||
var txtProduct = "{l s='product'}";
|
var txtProduct = "{l s='product'}";
|
||||||
var txtProducts = "{l s='products'}";
|
var txtProducts = "{l s='products'}";
|
||||||
// ]]>
|
// ]]>
|
||||||
|
{literal}
|
||||||
|
// Function to submit payment and send the information to GA
|
||||||
function submitPayment(){
|
function submitPayment(){
|
||||||
$input = $('input[name="paiement-method"]:checked');
|
$input = $('input[name="paiement-method"]:checked');
|
||||||
if(!$input.length) {
|
if(!$input.length) {
|
||||||
alert(paiementErrorMessage);
|
alert(paiementErrorMessage);
|
||||||
}
|
}
|
||||||
if ($input.val()) {
|
if ($input.val()) {
|
||||||
// redirect for GA send event
|
// redirect by GA send event
|
||||||
onStepComplete(4, $input.attr('data-module-name') ,$input.val(),null);
|
onStepComplete(4, $input.attr('data-module-name') ,$input.val(),null);
|
||||||
} else {
|
} else {
|
||||||
// LOADER POUR PAYPAL
|
// LOADER POUR PAYPAL
|
||||||
@ -49,10 +51,11 @@
|
|||||||
$('.box_paypal').fadeIn();
|
$('.box_paypal').fadeIn();
|
||||||
}
|
}
|
||||||
$form = $input.parent().children('div.hidden').children('form');
|
$form = $input.parent().children('div.hidden').children('form');
|
||||||
// submit form for GA send event
|
// submit form by GA send event
|
||||||
onStepComplete(4, $input.attr('data-module-name'),null,$form);
|
onStepComplete(4, $input.attr('data-module-name'),null,$form);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
{/literal}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{capture name=path}{l s='Your payment method'}{/capture}
|
{capture name=path}{l s='Your payment method'}{/capture}
|
||||||
|
Loading…
Reference in New Issue
Block a user