:q
Merge branch 'master' of gitlab.antadis.fr:dev-antadis/toutpratique
This commit is contained in:
commit
83c4baae0e
@ -1 +0,0 @@
|
||||
Subproject commit 768f0fb4e7dc72091791d8dfadcce6ba40cf8b23
|
@ -128,6 +128,10 @@ $(document).ready(function() {
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.layer_cart_overlay, #order #layer_cart .cross, #order #layer_cart .continue', function() {
|
||||
location.reload();
|
||||
});
|
||||
|
||||
// search tâches
|
||||
if(typeof tags != 'undefined') {
|
||||
$( "#cmsps-postsearch-tag" ).autocomplete({
|
||||
|
@ -1,27 +1,3 @@
|
||||
/*
|
||||
* 2007-2016 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2016 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
$(document).ready(function(){
|
||||
ajaxCart.overrideButtonsInThePage();
|
||||
|
||||
@ -34,10 +10,13 @@ $(document).ready(function(){
|
||||
ajaxCart.expand();
|
||||
});
|
||||
|
||||
var cart_qty = 0;
|
||||
var current_timestamp = parseInt(new Date().getTime() / 1000);
|
||||
|
||||
if (typeof $('.ajax_cart_quantity').html() == 'undefined' || (typeof generated_date != 'undefined' && generated_date != null && (parseInt(generated_date) + 30) < current_timestamp))
|
||||
ajaxCart.refresh();
|
||||
else
|
||||
cart_qty = parseInt($('.ajax_cart_quantity').html());
|
||||
|
||||
/* roll over cart */
|
||||
var cart_block = new HoverWatcher('#header .cart_block');
|
||||
@ -47,43 +26,15 @@ $(document).ready(function(){
|
||||
if ('ontouchstart' in document.documentElement)
|
||||
is_touch_enabled = true;
|
||||
|
||||
$(document).on('click', '#header .shopping_cart > a:first', function(e){
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
// Simulate hover when browser says device is touch based
|
||||
if (is_touch_enabled)
|
||||
{
|
||||
if ($(this).next('.cart_block:visible').length && !cart_block.isHoveringOver())
|
||||
$("#header .cart_block").stop(true, true).slideUp(450);
|
||||
else if (ajaxCart.nb_total_products > 0 || parseInt($('.ajax_cart_quantity').html()) > 0)
|
||||
$("#header .cart_block").stop(true, true).slideDown(450);
|
||||
return;
|
||||
}
|
||||
else
|
||||
window.location.href = $(this).attr('href');
|
||||
});
|
||||
|
||||
$("#header .shopping_cart a:first").hover(
|
||||
function(){
|
||||
if (ajaxCart.nb_total_products > 0 || parseInt($('.ajax_cart_quantity').html()) > 0)
|
||||
if (ajaxCart.nb_total_products > 0 || cart_qty > 0)
|
||||
$("#header .cart_block").stop(true, true).slideDown(450);
|
||||
},
|
||||
function(){
|
||||
setTimeout(function(){
|
||||
if (!shopping_cart.isHoveringOver() && !cart_block.isHoveringOver())
|
||||
$("#header .cart_block").stop(true, true).slideUp(450);
|
||||
}, 200);
|
||||
}
|
||||
);
|
||||
|
||||
$("#header .cart_block").hover(
|
||||
function(){
|
||||
},
|
||||
function(){
|
||||
setTimeout(function(){
|
||||
if (!shopping_cart.isHoveringOver())
|
||||
$("#header .cart_block").stop(true, true).slideUp(450);
|
||||
$("#header .cart_block").stop(true, true).slideUp(450);
|
||||
}, 200);
|
||||
}
|
||||
);
|
||||
@ -98,7 +49,6 @@ $(document).ready(function(){
|
||||
url:$(this).attr('href') + '?rand=' + new Date().getTime()
|
||||
});
|
||||
$(this).parent().parent().remove();
|
||||
ajaxCart.refresh();
|
||||
if ($('body').attr('id') == 'order' || $('body').attr('id') == 'order-opc')
|
||||
{
|
||||
if (typeof(updateAddressSelection) != 'undefined')
|
||||
@ -116,9 +66,9 @@ $(document).ready(function(){
|
||||
$(document).on('click', '#layer_cart .cross, #layer_cart .continue, .layer_cart_overlay', function(e){
|
||||
e.preventDefault();
|
||||
$('.layer_cart_overlay').hide();
|
||||
$('#layer_cart').fadeOut('fast');
|
||||
$('#layer_cart').removeClass('open');
|
||||
});
|
||||
|
||||
|
||||
$('#columns #layer_cart, #columns .layer_cart_overlay').detach().prependTo('#columns');
|
||||
});
|
||||
|
||||
@ -127,43 +77,33 @@ var ajaxCart = {
|
||||
nb_total_products: 0,
|
||||
//override every button in the page in relation to the cart
|
||||
overrideButtonsInThePage : function(){
|
||||
|
||||
//for every 'add' buttons...
|
||||
$(document).off('click', '.ajax_add_to_cart_button').on('click', '.ajax_add_to_cart_button', function(e){
|
||||
e.preventDefault();
|
||||
var idProduct = parseInt($(this).data('id-product'));
|
||||
var idProductAttribute = parseInt($(this).data('id-product-attribute'));
|
||||
var idProduct = parseInt($(this).attr('data-id-product'));
|
||||
var minimalQuantity = parseInt($(this).data('minimal_quantity'));
|
||||
if (!minimalQuantity)
|
||||
minimalQuantity = 1;
|
||||
if ($(this).prop('disabled') != 'disabled')
|
||||
ajaxCart.add(idProduct, idProductAttribute, false, this, minimalQuantity);
|
||||
ajaxCart.add(idProduct, null, false, this, minimalQuantity);
|
||||
});
|
||||
//for product page 'add' button...
|
||||
if ($('.cart_block').length) {
|
||||
$(document).off('click', '#add_to_cart button').on('click', '#add_to_cart button', function(e){
|
||||
e.preventDefault();
|
||||
ajaxCart.add($('#product_page_product_id').val(), $('#idCombination').val(), true, null, $('#quantity_wanted').val(), null);
|
||||
console.log('test');
|
||||
});
|
||||
}
|
||||
|
||||
if ($('.cart_block_product_accessories').length) {
|
||||
$(document).off('click', '#add_to_cart button').on('click', '#add_to_cart button', function(e){
|
||||
e.preventDefault();
|
||||
var idProduct = parseInt($(this).parent().data('id-product'));
|
||||
ajaxCart.add(idProduct, 0, false, null, 1, null, false);
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
//for product page 'add' button...
|
||||
$(document).on('click', '#add_to_cart button', function(e){
|
||||
e.preventDefault();
|
||||
ajaxCart.add($('#product_page_product_id').val(), $('#idCombination').val(), true, null, $('#quantity_wanted').val(), null);
|
||||
});
|
||||
|
||||
//for 'delete' buttons in the cart block...
|
||||
$(document).off('click', '.cart_block_list .ajax_cart_block_remove_link').on('click', '.cart_block_list .ajax_cart_block_remove_link', function(e){
|
||||
$('.cart_block_list .ajax_cart_block_remove_link').unbind('click').click(function(e){
|
||||
|
||||
e.preventDefault();
|
||||
// Customized product management
|
||||
var customizationId = 0;
|
||||
var productId = 0;
|
||||
var productAttributeId = 0;
|
||||
var customizableProductDiv = $($(this).parent().parent()).find("div[data-id^=deleteCustomizableProduct_]");
|
||||
var customizableProductDiv = $($(this).parent().parent());
|
||||
var idAddressDelivery = false;
|
||||
|
||||
if (customizableProductDiv && $(customizableProductDiv).length)
|
||||
@ -224,7 +164,7 @@ var ajaxCart = {
|
||||
$('.block_cart_expand').fadeOut('fast', function(){
|
||||
$('.block_cart_collapse').fadeIn('fast');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -258,11 +198,11 @@ var ajaxCart = {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: (typeof(baseUri) !== 'undefined') ? baseUri + '?rand=' + new Date().getTime() : '',
|
||||
url: baseUri + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: (typeof(static_token) !== 'undefined') ? 'controller=cart&ajax=true&token=' + static_token : '',
|
||||
data: 'controller=cart&ajax=true&token=' + static_token,
|
||||
success: function(jsonData)
|
||||
{
|
||||
ajaxCart.updateCart(jsonData);
|
||||
@ -274,7 +214,7 @@ var ajaxCart = {
|
||||
updateCartInformation : function (jsonData, addedFromProductPage){
|
||||
ajaxCart.updateCart(jsonData);
|
||||
//reactive the button when adding has finished
|
||||
if (addedFromProductPage)
|
||||
if (addedFromProductPage)
|
||||
{
|
||||
$('#add_to_cart button').removeProp('disabled').removeClass('disabled');
|
||||
if (!jsonData.hasError || jsonData.hasError == false)
|
||||
@ -288,37 +228,78 @@ var ajaxCart = {
|
||||
// close fancybox
|
||||
updateFancyBox : function (){},
|
||||
// add a product in the cart via ajax
|
||||
add : function(idProduct, idCombination, addedFromProductPage, callerElement, quantity, whishlist, fancyboxOpen){
|
||||
if(typeof fancyboxOpen == "undefined") {
|
||||
fancyboxOpen = true;
|
||||
addMultiple : function(idProduct, idCombination, quantity) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: baseUri + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'controller=cart&add=1&ajax=true&qty=' + ((quantity && quantity != null) ? quantity : '1') + '&id_product=' + idProduct + '&token=' + static_token + ( (parseInt(idCombination) && idCombination != null) ? '&ipa=' + parseInt(idCombination): ''),
|
||||
success: function(jsonData,textStatus,jqXHR) {
|
||||
if (!jsonData.hasError) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
// error: function(XMLHttpRequest, textStatus, errorThrown)
|
||||
// {
|
||||
// var error = "Impossible to add the product to the cart.<br/>textStatus: '" + textStatus + "'<br/>errorThrown: '" + errorThrown + "'<br/>responseText:<br/>" + XMLHttpRequest.responseText;
|
||||
// if (!!$.prototype.fancybox)
|
||||
// $.fancybox.open([
|
||||
// {
|
||||
// type: 'inline',
|
||||
// autoScale: true,
|
||||
// minHeight: 30,
|
||||
// content: '<p class="fancybox-error">' + error + '</p>'
|
||||
// }],
|
||||
// {
|
||||
// padding: 0
|
||||
// });
|
||||
// else
|
||||
// alert(error);
|
||||
// }
|
||||
});
|
||||
},
|
||||
|
||||
returnStatus : function(data) {
|
||||
return data.hasError;
|
||||
},
|
||||
|
||||
add : function(idProduct, idCombination, addedFromProductPage, callerElement, quantity, whishlist, fromPack){
|
||||
|
||||
if(typeof(fromPack) === 'undefined')
|
||||
{
|
||||
fromPack = false;
|
||||
}
|
||||
|
||||
if (addedFromProductPage && !checkCustomizations())
|
||||
{
|
||||
if (contentOnly)
|
||||
if (contentOnly)
|
||||
{
|
||||
var productUrl = window.document.location.href + '';
|
||||
var data = productUrl.replace('content_only=1', '');
|
||||
window.parent.document.location.href = data;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!!$.prototype.fancybox)
|
||||
$.fancybox.open([
|
||||
{
|
||||
type: 'inline',
|
||||
autoScale: true,
|
||||
minHeight: 30,
|
||||
content: '<p class="fancybox-error">' + fieldRequired + '</p>'
|
||||
}
|
||||
], {
|
||||
padding: 0
|
||||
});
|
||||
$.fancybox.open([
|
||||
{
|
||||
type: 'inline',
|
||||
autoScale: true,
|
||||
minHeight: 30,
|
||||
content: '<p class="fancybox-error">' + fieldRequired + '</p>'
|
||||
}
|
||||
], {
|
||||
padding: 0
|
||||
});
|
||||
else
|
||||
alert(fieldRequired);
|
||||
return;
|
||||
alert(fieldRequired);
|
||||
return;
|
||||
}
|
||||
|
||||
emptyCustomizations();
|
||||
//disabled the button when adding to not double add if user double click
|
||||
if (addedFromProductPage)
|
||||
{
|
||||
@ -339,13 +320,13 @@ var ajaxCart = {
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'controller=cart&add=1&ajax=true&qty=' + ((quantity && quantity != null) ? quantity : '1') + '&id_product=' + idProduct + '&token=' + static_token + ( (parseInt(idCombination) && idCombination != null) ? '&ipa=' + parseInt(idCombination): '' + '&id_customization=' + ((typeof customizationId !== 'undefined') ? customizationId : 0)),
|
||||
data: 'controller=cart&add=1&ajax=true&qty=' + ((quantity && quantity != null) ? quantity : '1') + '&id_product=' + idProduct + '&token=' + static_token + ( (parseInt(idCombination) && idCombination != null) ? '&ipa=' + parseInt(idCombination): ''),
|
||||
success: function(jsonData,textStatus,jqXHR)
|
||||
{
|
||||
// add appliance to whishlist module
|
||||
if (whishlist && !jsonData.errors)
|
||||
WishlistAddProductCart(whishlist[0], idProduct, idCombination, whishlist[1]);
|
||||
|
||||
|
||||
if (!jsonData.hasError)
|
||||
{
|
||||
if (contentOnly)
|
||||
@ -355,65 +336,57 @@ var ajaxCart = {
|
||||
|
||||
if (jsonData.crossSelling)
|
||||
$('.crossseling').html(jsonData.crossSelling);
|
||||
else
|
||||
$('.crossseling').html('');
|
||||
|
||||
if(fancyboxOpen) {
|
||||
if (idCombination)
|
||||
$(jsonData.products).each(function(){
|
||||
if (this.id != undefined && this.id == parseInt(idProduct) && this.idCombination == parseInt(idCombination))
|
||||
if (contentOnly)
|
||||
window.parent.ajaxCart.updateLayer(this);
|
||||
else
|
||||
ajaxCart.updateLayer(this);
|
||||
});
|
||||
else
|
||||
$(jsonData.products).each(function(){
|
||||
if (this.id != undefined && this.id == parseInt(idProduct))
|
||||
if (contentOnly)
|
||||
window.parent.ajaxCart.updateLayer(this);
|
||||
else
|
||||
ajaxCart.updateLayer(this);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if(!fancyboxOpen) {
|
||||
if (idCombination)
|
||||
$(jsonData.products).each(function(){
|
||||
if (this.id != undefined && this.id == parseInt(idProduct) && this.idCombination == parseInt(idCombination) && !fromPack)
|
||||
if (contentOnly)
|
||||
window.parent.ajaxCart.updateLayer(this);
|
||||
else
|
||||
ajaxCart.updateLayer(this);
|
||||
});
|
||||
else
|
||||
$(jsonData.products).each(function(){
|
||||
if (this.id != undefined && this.id == parseInt(idProduct) && !fromPack)
|
||||
if (contentOnly)
|
||||
window.parent.ajaxCart.updateLayer(this);
|
||||
else
|
||||
ajaxCart.updateLayer(this);
|
||||
});
|
||||
if (contentOnly)
|
||||
parent.$.fancybox.close();
|
||||
} else {
|
||||
if (contentOnly)
|
||||
parent.$.fancybox.close();
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
if (contentOnly)
|
||||
window.parent.ajaxCart.updateCart(jsonData);
|
||||
else
|
||||
ajaxCart.updateCart(jsonData);
|
||||
ajaxCart.updateCart(jsonData);
|
||||
if (addedFromProductPage)
|
||||
$('#add_to_cart button').removeProp('disabled').removeClass('disabled');
|
||||
else
|
||||
$(callerElement).removeProp('disabled');
|
||||
}
|
||||
|
||||
emptyCustomizations();
|
||||
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown)
|
||||
{
|
||||
var error = "Impossible to add the product to the cart.<br/>textStatus: '" + textStatus + "'<br/>errorThrown: '" + errorThrown + "'<br/>responseText:<br/>" + XMLHttpRequest.responseText;
|
||||
if (!!$.prototype.fancybox)
|
||||
$.fancybox.open([
|
||||
$.fancybox.open([
|
||||
{
|
||||
type: 'inline',
|
||||
autoScale: true,
|
||||
minHeight: 30,
|
||||
content: '<p class="fancybox-error">' + error + '</p>'
|
||||
}],
|
||||
{
|
||||
type: 'inline',
|
||||
autoScale: true,
|
||||
minHeight: 30,
|
||||
content: '<p class="fancybox-error">' + error + '</p>'
|
||||
}],
|
||||
{
|
||||
padding: 0
|
||||
});
|
||||
padding: 0
|
||||
});
|
||||
else
|
||||
alert(error);
|
||||
alert(error);
|
||||
//reactive the button when adding has finished
|
||||
if (addedFromProductPage)
|
||||
$('#add_to_cart button').removeProp('disabled').removeClass('disabled');
|
||||
@ -440,24 +413,24 @@ var ajaxCart = {
|
||||
deleteProductFromSummary(idProduct+'_'+idCombination+'_'+customizationId+'_'+idAddressDelivery);
|
||||
},
|
||||
error: function()
|
||||
{
|
||||
{
|
||||
var error = 'ERROR: unable to delete the product';
|
||||
if (!!$.prototype.fancybox)
|
||||
{
|
||||
$.fancybox.open([
|
||||
{
|
||||
type: 'inline',
|
||||
autoScale: true,
|
||||
minHeight: 30,
|
||||
content: error
|
||||
}
|
||||
], {
|
||||
padding: 0
|
||||
});
|
||||
$.fancybox.open([
|
||||
{
|
||||
type: 'inline',
|
||||
autoScale: true,
|
||||
minHeight: 30,
|
||||
content: error
|
||||
}
|
||||
], {
|
||||
padding: 0
|
||||
});
|
||||
}
|
||||
else
|
||||
alert(error);
|
||||
}
|
||||
alert(error);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@ -504,7 +477,6 @@ var ajaxCart = {
|
||||
// If the cart is now empty, show the 'no product in the cart' message and close detail
|
||||
if($('.cart_block:first dl.products dt').length == 0)
|
||||
{
|
||||
$('.ajax_cart_quantity').html('0');
|
||||
$("#header .cart_block").stop(true, true).slideUp(200);
|
||||
$('.cart_block_no_products:hidden').slideDown(450);
|
||||
$('.cart_block dl.products').remove();
|
||||
@ -629,20 +601,22 @@ var ajaxCart = {
|
||||
{
|
||||
var productId = parseInt(this.id);
|
||||
var productAttributeId = (this.hasAttributes ? parseInt(this.attributes) : 0);
|
||||
var content = '<dt class="unvisible" data-id="cart_block_product_' + domIdProduct + '">';
|
||||
var content = '<dt class="panel-product unvisible" data-id="cart_block_product_' + domIdProduct + '">';
|
||||
var name = $.trim($('<span />').html(this.name).text());
|
||||
name = (name.length > 12 ? name.substring(0, 10) + '...' : name);
|
||||
content += '<a class="cart-images" href="' + this.link + '" title="' + name + '"><img src="' + this.image_cart + '" alt="' + this.name +'"></a>';
|
||||
content += '<div class="cart-info"><div class="product-name">' + '<span class="quantity-formated"><span class="quantity">' + this.quantity + '</span> x </span><a href="' + this.link + '" title="' + this.name + '" class="cart_block_product_name">' + name + '</a></div>';
|
||||
if (this.hasAttributes)
|
||||
content += '<div class="product-atributes"><a href="' + this.link + '" title="' + this.name + '">' + this.attributes + '</a></div>';
|
||||
content += '<div class="row">';
|
||||
content += '<a class="panel-product-img cart-images" href="' + this.link + '" title="' + name + '"><img src="' + this.image + '" alt="' + this.name +'"></a>';
|
||||
content += '<div class="panel-product-info cart-info">';
|
||||
content += '<div class="panel-product-category">'+ this.category_name + '</div>';
|
||||
content += '<div class="panel-product-title product-name"><a href="' + this.link + '" title="' + this.name + '" class="cart_block_product_name">' + name + '</a></div>';
|
||||
|
||||
if (typeof(freeProductTranslation) != 'undefined')
|
||||
content += '<span class="price">' + (parseFloat(this.price_float) > 0 ? this.priceByLine : freeProductTranslation) + '</span></div>';
|
||||
content += '<span class="panel-product-price price">' + (parseFloat(this.price_float) > 0 ? this.priceByLine : freeProductTranslation) + '</span></div>';
|
||||
|
||||
if (typeof(this.is_gift) == 'undefined' || this.is_gift == 0)
|
||||
content += '<span class="remove_link"><a rel="nofollow" class="ajax_cart_block_remove_link" href="' + baseUri + '?controller=cart&delete=1&id_product=' + productId + '&token=' + static_token + (this.hasAttributes ? '&ipa=' + parseInt(this.idCombination) : '') + '"> </a></span>';
|
||||
content += '<a rel="nofollow" class="icon-close ajax_cart_block_remove_link icon" href="' + baseUri + '?controller=cart&delete=1&id_product=' + productId + '&token=' + static_token + (this.hasAttributes ? '&ipa=' + parseInt(this.idCombination) : '') + '"> </a>';
|
||||
else
|
||||
content += '<span class="remove_link"></span>';
|
||||
content += '</div>';
|
||||
content += '</dt>';
|
||||
if (this.hasAttributes)
|
||||
content += '<dd data-id="cart_block_combination_of_' + domIdProduct + '" class="unvisible">';
|
||||
@ -693,6 +667,7 @@ var ajaxCart = {
|
||||
});
|
||||
}
|
||||
});
|
||||
this.overrideButtonsInThePage();
|
||||
},
|
||||
|
||||
displayNewCustomizedDatas : function(product){
|
||||
@ -751,21 +726,59 @@ var ajaxCart = {
|
||||
},
|
||||
|
||||
updateLayer : function(product){
|
||||
$('#layer_cart_product_title').text(product.name);
|
||||
$('#layer_cart_product_attributes').text('');
|
||||
if (product.hasAttributes && product.hasAttributes == true)
|
||||
$('#layer_cart_product_attributes').html(product.attributes);
|
||||
$('#layer_cart_product_price').text(product.price);
|
||||
$('#layer_cart_product_quantity').text(product.quantity);
|
||||
$('.layer_cart_img').html('<img class="layer_cart_img img-responsive" src="' + product.image + '" alt="' + product.name + '" title="' + product.name + '" />');
|
||||
var id_product = product.id;
|
||||
var idCombination = product.idCombination;
|
||||
var quantity = 1;
|
||||
if($("#quantity_wanted").val()){
|
||||
quantity = $("#quantity_wanted").val();
|
||||
}
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: baseUri + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'controller=product&action=getProductInfo&ajax=true&token=' + static_token + '&id_product=' + id_product + '&idCombination=' +idCombination + '&qty=' +quantity,
|
||||
success : function(data) {
|
||||
if(data.found)
|
||||
{
|
||||
if(ajaxCart.updateWithNewInfo(data))
|
||||
{
|
||||
|
||||
var n = parseInt($(window).scrollTop()) + 'px';
|
||||
$('#layer_cart').addClass('open');
|
||||
$('#layer_cart .panel-overlay').addClass('open');
|
||||
$('.layer_cart_overlay').fadeIn();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
$('.layer_cart_overlay').css('width','100%');
|
||||
$('.layer_cart_overlay').css('height','100%');
|
||||
$('.layer_cart_overlay').show();
|
||||
$('#layer_cart').css({'top': n}).fadeIn('fast');
|
||||
crossselling_serialScroll();
|
||||
updateInfoCart: function(quantity_add) {
|
||||
var actual = $('#header-cart .ajax_cart_quantity').html();
|
||||
actual = actual.replace("(", "");
|
||||
actual = actual.replace(")", "");
|
||||
var totalCart = parseInt(actual) + parseInt(quantity_add);
|
||||
$('#header-cart .ajax_cart_quantity').html('('+totalCart+')');
|
||||
},
|
||||
|
||||
updateWithNewInfo : function(data){
|
||||
$(".layer_cart_product .product-image-container").html('<img class="img-responsive" src="'+data.product.img+'" />');
|
||||
$(".layer_cart_product .product-name").html(data.product.name);
|
||||
$(".layer_cart_product .product-price").html(data.product.productPrice);
|
||||
$(".layer_cart_product .nb_quantity").html(data.product.quantity_in_cart);
|
||||
|
||||
if (data.product.specificPrice) {
|
||||
$(".layer_cart_product .product-old-price .value").html(data.product.productPriceWithoutReduction);
|
||||
} else {
|
||||
$('.product-old-price').hide();
|
||||
}
|
||||
|
||||
var n = parseInt($(window).scrollTop() + 20) + 'px';
|
||||
$('#layer_cart').css({'top': n});
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
//genarally update the display of the cart
|
||||
@ -779,18 +792,18 @@ var ajaxCart = {
|
||||
if (error != 'indexOf')
|
||||
errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
|
||||
if (!!$.prototype.fancybox)
|
||||
$.fancybox.open([
|
||||
{
|
||||
type: 'inline',
|
||||
autoScale: true,
|
||||
minHeight: 30,
|
||||
content: '<p class="fancybox-error">' + errors + '</p>'
|
||||
}
|
||||
], {
|
||||
padding: 0
|
||||
});
|
||||
$.fancybox.open([
|
||||
{
|
||||
type: 'inline',
|
||||
autoScale: true,
|
||||
minHeight: 30,
|
||||
content: '<p class="fancybox-error">' + errors + '</p>'
|
||||
}
|
||||
], {
|
||||
padding: 0
|
||||
});
|
||||
else
|
||||
alert(errors);
|
||||
alert(errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -809,28 +822,19 @@ var ajaxCart = {
|
||||
|
||||
//update general cart informations everywhere in the page
|
||||
updateCartEverywhere : function(jsonData){
|
||||
|
||||
$('.ajax_cart_total').text($.trim(jsonData.productTotal));
|
||||
|
||||
if (typeof hasDeliveryAddress == 'undefined')
|
||||
hasDeliveryAddress = false;
|
||||
|
||||
if (parseFloat(jsonData.shippingCostFloat) > 0)
|
||||
$('.ajax_cart_shipping_cost').text(jsonData.shippingCost).parent().find('.unvisible').show();
|
||||
else if ((hasDeliveryAddress || typeof(orderProcess) !== 'undefined' && orderProcess == 'order-opc') && typeof(freeShippingTranslation) != 'undefined')
|
||||
$('.ajax_cart_shipping_cost').html(freeShippingTranslation);
|
||||
else if ((typeof toBeDetermined !== 'undefined') && !hasDeliveryAddress)
|
||||
$('.ajax_cart_shipping_cost').html(toBeDetermined);
|
||||
|
||||
if (!jsonData.shippingCostFloat && !jsonData.free_ship)
|
||||
$('.ajax_cart_shipping_cost').parent().find('.unvisible').hide();
|
||||
else if (hasDeliveryAddress && !jsonData.isVirtualCart)
|
||||
$('.ajax_cart_shipping_cost').parent().find('.unvisible').show();
|
||||
$('.ajax_cart_shipping_cost').text(jsonData.shippingCost);
|
||||
else if (typeof(freeShippingTranslation) != 'undefined')
|
||||
$('.ajax_cart_shipping_cost').html(freeShippingTranslation);
|
||||
|
||||
$('.ajax_cart_tax_cost').text(jsonData.taxCost);
|
||||
$('.cart_block_wrapping_cost').text(jsonData.wrappingCost);
|
||||
$('.ajax_block_cart_total').text(jsonData.total);
|
||||
$('.ajax_block_products_total').text(jsonData.productTotal);
|
||||
$('.ajax_total_price_wt').text(jsonData.total_price_wt);
|
||||
$('.ajax_total_price_wt').text(jsonData.total_price_wt);
|
||||
|
||||
if (parseFloat(jsonData.freeShippingFloat) > 0)
|
||||
{
|
||||
@ -841,11 +845,12 @@ var ajaxCart = {
|
||||
$('.freeshipping').fadeOut(0);
|
||||
|
||||
this.nb_total_products = jsonData.nbTotalProducts;
|
||||
|
||||
$('.ajax_cart_quantity').text('('+jsonData.nbTotalProducts+')');
|
||||
|
||||
if (parseInt(jsonData.nbTotalProducts) > 0)
|
||||
{
|
||||
$('.ajax_cart_no_product').hide();
|
||||
$('.ajax_cart_quantity').text(jsonData.nbTotalProducts);
|
||||
$('.ajax_cart_quantity').fadeIn('slow');
|
||||
$('.ajax_cart_total').fadeIn('slow');
|
||||
|
||||
@ -872,7 +877,7 @@ var ajaxCart = {
|
||||
}
|
||||
else
|
||||
{
|
||||
$('.ajax_cart_quantity, .ajax_cart_product_txt_s, .ajax_cart_product_txt, .ajax_cart_total').each(function(){
|
||||
$('.ajax_cart_product_txt_s, .ajax_cart_product_txt, .ajax_cart_total').each(function(){
|
||||
$(this).hide();
|
||||
});
|
||||
$('.ajax_cart_no_product').show('slow');
|
||||
@ -906,7 +911,7 @@ function crossselling_serialScroll()
|
||||
slideMargin: 20,
|
||||
moveSlides: 1,
|
||||
infiniteLoop: false,
|
||||
hideControlOnEnd: true,
|
||||
hideControlOnEnd: true,
|
||||
pager: false
|
||||
});
|
||||
}
|
||||
}
|
@ -104,7 +104,11 @@
|
||||
<div class="btnWrap col-md-7 col-sm-12">
|
||||
{if ($showAccessory['product']->id_product_attribute == 0 OR (isset($add_prod_display) AND ($add_prod_display == 1))) AND $showAccessory['product']->available_for_order AND !isset($restricted_country_mode) AND $showAccessory['product']->minimal_quantity == 1 AND $showAccessory['product']->customizable != 2}
|
||||
{if ($showAccessory['quantity'] > 0 OR $showAccessory['product']->allow_oosp)}
|
||||
<p id="add_to_cart" class="buttons_bottom_block no-print cart_block_product_accessories" data-id-product="{$showAccessory['id_product']}">
|
||||
<p
|
||||
class="buttons_bottom_block no-print ajax_add_to_cart_button cart_block_product_accessories"
|
||||
data-minimal_quantity="1"
|
||||
data-id-product="{$showAccessory['id_product']}"
|
||||
>
|
||||
<button type="submit" name="Submit" class="exclusive btn btn-cart">
|
||||
<span><i class="icon icon-shopping-cart"></i>{l s='Ajouter au panier' mod='productaccessories'}</span>
|
||||
</button>
|
||||
@ -127,4 +131,5 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user