[-] FO : Fix bug #PSCFV-7946 delete customized product with several custos
This commit is contained in:
@@ -52,11 +52,8 @@ var ajaxCart = {
|
||||
var customizationId = 0;
|
||||
var productId = 0;
|
||||
var productAttributeId = 0;
|
||||
if ($($(this).parent().parent()).attr('name') == 'customization')
|
||||
// Reverse two levels: a >> div >> li
|
||||
var customizableProductDiv = $($(this).parent().parent()).find("div[id^=deleteCustomizableProduct_]");
|
||||
else
|
||||
var customizableProductDiv = $($(this).parent()).find("div[id^=deleteCustomizableProduct_]");
|
||||
var customizableProductDiv = $($(this).parent().parent()).find("div[id^=deleteCustomizableProduct_]");
|
||||
|
||||
if (customizableProductDiv && $(customizableProductDiv).length)
|
||||
{
|
||||
$(customizableProductDiv).each(function(){
|
||||
@@ -185,7 +182,7 @@ var ajaxCart = {
|
||||
return ;
|
||||
}
|
||||
emptyCustomizations();
|
||||
//disabled the button when adding to do not double add if user double click
|
||||
//disabled the button when adding to not double add if user double click
|
||||
if (addedFromProductPage)
|
||||
{
|
||||
$('#add_to_cart input').attr('disabled', true).removeClass('exclusive').addClass('exclusive_disabled');
|
||||
@@ -466,9 +463,10 @@ var ajaxCart = {
|
||||
//else update the product's line
|
||||
else
|
||||
{
|
||||
var jsonProduct = this;
|
||||
if($('#cart_block_product_' + domIdProduct + ' .quantity').text() != jsonProduct.quantity || $('dt#cart_block_product_' + domIdProduct + ' .price').text() != jsonProduct.priceByLine)
|
||||
var jsonProduct = this;
|
||||
if($.trim($('#cart_block_product_' + domIdProduct + ' .quantity').text()) != jsonProduct.quantity || $.trim($('dt#cart_block_product_' + domIdProduct + ' .price').text()) != jsonProduct.priceByLine)
|
||||
{
|
||||
|
||||
// Usual product
|
||||
if (!this.is_gift)
|
||||
$('#cart_block_product_' + domIdProduct + ' .price').text(jsonProduct.priceByLine);
|
||||
@@ -521,11 +519,12 @@ var ajaxCart = {
|
||||
content += '<ul class="cart_block_customizations" id="customization_' + productId + '_' + productAttributeId + '">';
|
||||
}
|
||||
|
||||
$(product.customizedDatas).each(function(){
|
||||
$(product.customizedDatas).each(function()
|
||||
{
|
||||
var done = 0;
|
||||
customizationId = parseInt(this.customizationId);
|
||||
productAttributeId = typeof(product.idCombination) == 'undefined' ? 0 : parseInt(product.idCombination);
|
||||
content += '<li name="customization"><div class="deleteCustomizableProduct" id="deleteCustomizableProduct_' + customizationId + '_' + productId + '_' + (productAttributeId ? productAttributeId : '0') + '"><a rel="nofollow" class="ajax_cart_block_remove_link" href="' + baseUri + '?controller=cart&delete=1&id_product=' + productId + '&ipa=' + productAttributeId + '&id_customization=' + customizationId + '&token=' + static_token + '"> </a></div><span class="quantity-formated"><span class="quantity">' + parseInt(this.quantity) + '</span>x</span>';
|
||||
content += '<li name="customization"><div class="deleteCustomizableProduct" id="deleteCustomizableProduct_' + customizationId + '_' + productId + '_' + (productAttributeId ? productAttributeId : '0') + '"><a rel="nofollow" class="ajax_cart_block_remove_link" href="' + baseUri + '?controller=cart&delete=1&id_product=' + productId + '&ipa=' + productAttributeId + '&id_customization=' + customizationId + '&token=' + static_token + '"></a></div><span class="quantity-formated"><span class="quantity">' + parseInt(this.quantity) + '</span>x</span>';
|
||||
|
||||
// Give to the customized product the first textfield value as name
|
||||
$(this.datas).each(function(){
|
||||
@@ -595,7 +594,7 @@ var ajaxCart = {
|
||||
|
||||
//update general cart informations everywhere in the page
|
||||
updateCartEverywhere : function(jsonData) {
|
||||
$('.ajax_cart_total').text(jsonData.productTotal);
|
||||
$('.ajax_cart_total').text($.trim(jsonData.productTotal));
|
||||
|
||||
if (parseFloat(jsonData.shippingCostFloat) > 0 || jsonData.nbTotalProducts < 1)
|
||||
$('.ajax_cart_shipping_cost').text(jsonData.shippingCost);
|
||||
|
||||
@@ -490,7 +490,10 @@ ul#uploadable_files,ul#text_fields {
|
||||
.customizationUploadLine {
|
||||
padding-bottom:10px;
|
||||
}
|
||||
|
||||
.customizationUploadBrowse img + a {
|
||||
position: relative;
|
||||
top: -51px;
|
||||
}
|
||||
.customizationUploadLine label {
|
||||
display:inline-block;
|
||||
width:150px;
|
||||
|
||||
@@ -282,7 +282,8 @@ function deleteProductFromSummary(id)
|
||||
+'&ajax=true&delete=true&summary=true'
|
||||
+'&id_product='+productId
|
||||
+'&ipa='+productAttributeId
|
||||
+'&id_address_delivery='+id_address_delivery+ ( (customizationId !== 0) ? '&id_customization='+customizationId : '')
|
||||
+'&id_address_delivery='+id_address_delivery
|
||||
+ ((customizationId !== 0) ? '&id_customization=' + customizationId : '')
|
||||
+'&token=' + static_token
|
||||
+'&allow_refresh=1',
|
||||
success: function(jsonData)
|
||||
@@ -334,17 +335,18 @@ function deleteProductFromSummary(id)
|
||||
exist = true;
|
||||
|
||||
// if all customization removed => delete product line
|
||||
if (!exist && customizationId)
|
||||
if (!exist && customizationId && parseInt($('#cart_quantity_custom_' + productId + (productAttributeId > 0 ? '_' + productAttributeId : '') + '_0_' + id_address_delivery).html()) == 1)
|
||||
$('#product_' + productId + '_' + productAttributeId + '_0_' + id_address_delivery).fadeOut('slow', function() {
|
||||
$(this).remove();
|
||||
refreshOddRow();
|
||||
});
|
||||
}
|
||||
|
||||
updateCartSummary(jsonData.summary);
|
||||
updateCustomizedDatas(jsonData.customizedDatas);
|
||||
updateHookShoppingCart(jsonData.HOOK_SHOPPING_CART);
|
||||
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
|
||||
if (typeof(getCarrierListAndUpdate) !== 'undefined')
|
||||
if (typeof(getCarrierListAndUpdate) !== 'undefined' && jsonData.summary.products.length > 0)
|
||||
getCarrierListAndUpdate();
|
||||
}
|
||||
},
|
||||
@@ -589,42 +591,36 @@ function updateCartSummary(json)
|
||||
if (reduction && typeof(initial_price) !== 'undefined')
|
||||
{
|
||||
if (initial_price !== '' && product_list[i].price_without_quantity_discount > product_list[i].price)
|
||||
initial_price_text = '<span style="text-decoration:line-through;">'+initial_price+'</span><br />';
|
||||
initial_price_text = '<span style="text-decoration:line-through;">' + initial_price + '</span><br />';
|
||||
}
|
||||
|
||||
key_for_blockcart = product_list[i].id_product+'_'+product_list[i].id_product_attribute+'_'+product_list[i].id_address_delivery;
|
||||
key_for_blockcart = product_list[i].id_product + '_' + product_list[i].id_product_attribute + '_' + product_list[i].id_address_delivery;
|
||||
|
||||
$('#cart_block_product_'+key_for_blockcart+' span.quantity').html(product_list[i].quantity);
|
||||
$('#cart_block_product_'+ key_for_blockcart + ' span.quantity').html(product_list[i].quantity);
|
||||
|
||||
if (priceDisplayMethod !== 0)
|
||||
{
|
||||
$('#cart_block_product_'+key_for_blockcart+' span.price').html(formatCurrency(product_list[i].total, currencyFormat, currencySign, currencyBlank));
|
||||
$('#product_price_'+product_list[i].id_product+'_'+product_list[i].id_product_attribute+'_'+product_list[i].id_address_delivery).html(initial_price_text+current_price);
|
||||
$('#total_product_price_'+product_list[i].id_product+'_'+product_list[i].id_product_attribute+'_'+product_list[i].id_address_delivery).html(formatCurrency(product_list[i].total, currencyFormat, currencySign, currencyBlank));
|
||||
$('#cart_block_product_' + key_for_blockcart + ' span.price').html(formatCurrency(product_list[i].total, currencyFormat, currencySign, currencyBlank));
|
||||
$('#product_price_' + key_for_blockcart).html(initial_price_text+current_price);
|
||||
$('#total_product_price_' + key_for_blockcart).html(formatCurrency(product_list[i].total, currencyFormat, currencySign, currencyBlank));
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#cart_block_product_'+key_for_blockcart+' span.price').html(formatCurrency(product_list[i].total_wt, currencyFormat, currencySign, currencyBlank));
|
||||
$('#product_price_'+product_list[i].id_product+'_'+product_list[i].id_product_attribute+'_'+product_list[i].id_address_delivery).html(initial_price_text+current_price);
|
||||
$('#total_product_price_'+product_list[i].id_product+'_'+product_list[i].id_product_attribute+'_'+product_list[i].id_address_delivery).html(formatCurrency(product_list[i].total_wt, currencyFormat, currencySign, currencyBlank));
|
||||
$('#cart_block_product_' + key_for_blockcart + ' span.price').html(formatCurrency(product_list[i].total_wt, currencyFormat, currencySign, currencyBlank));
|
||||
$('#product_price_' + key_for_blockcart).html(initial_price_text+current_price);
|
||||
$('#total_product_price_' + key_for_blockcart).html(formatCurrency(product_list[i].total_wt, currencyFormat, currencySign, currencyBlank));
|
||||
}
|
||||
|
||||
nbrProducts += parseInt(product_list[i].quantity);
|
||||
$('input[name=quantity_'+product_list[i].id_product+'_'+product_list[i].id_product_attribute+'_0_'+product_list[i].id_address_delivery+']').val(product_list[i].quantity_without_customization);
|
||||
$('input[name=quantity_'+product_list[i].id_product+'_'+product_list[i].id_product_attribute+'_0_'+product_list[i].id_address_delivery+'_hidden]').val(product_list[i].quantity_without_customization);
|
||||
$('input[name=quantity_' + product_list[i].id_product + '_' + product_list[i].id_product_attribute + '_0_' + product_list[i].id_address_delivery + ']').val(product_list[i].quantity_without_customization);
|
||||
$('input[name=quantity_' + product_list[i].id_product + '_' + product_list[i].id_product_attribute + '_0_' + product_list[i].id_address_delivery + '_hidden]').val(product_list[i].quantity_without_customization);
|
||||
|
||||
if (typeof(product_list[i].customizationQuantityTotal) !== 'undefined')
|
||||
{
|
||||
$('#cart_quantity_custom_'+product_list[i].id_product+'_'+product_list[i].id_product_attribute+'_'+product_list[i].id_address_delivery)
|
||||
$('#cart_quantity_custom_' + key_for_blockcart)
|
||||
.html(product_list[i].customizationQuantityTotal);
|
||||
$('input[name=quantity_'+product_list[i].id_product+'_'+product_list[i].id_product_attribute+'_'+product_list[i].id_customization+'_'+product_list[i].id_address_delivery+']')
|
||||
.val(product_list[i].customizationQuantityTotal);
|
||||
$('input[name=quantity_' + product_list[i].id_product + '_' + product_list[i].id_product_attribute + '_' + product_list[i].id_customization + '_' + product_list[i].id_address_delivery + ']').val(product_list[i].customizationQuantityTotal);
|
||||
}
|
||||
// Show / hide quantity button if minimal quantity
|
||||
if (parseInt(product_list[i].minimal_quantity) === parseInt(product_list[i].quantity) && product_list[i].minimal_quantity !== 1)
|
||||
$('#cart_quantity_down_'+product_list[i].id_product+'_'+product_list[i].id_product_attribute+'_'+Number(product_list[i].id_customization)+'_'+product_list[i].id_address_delivery).fadeTo('slow',0.3);
|
||||
else
|
||||
$('#cart_quantity_down_'+product_list[i].id_product+'_'+product_list[i].id_product_attribute+'_'+Number(product_list[i].id_customization)+'_'+product_list[i].id_address_delivery).fadeTo('slow',1);
|
||||
}
|
||||
|
||||
// Update discounts
|
||||
|
||||
@@ -174,19 +174,19 @@ function getCarrierListAndUpdate()
|
||||
data: 'ajax=true&method=getCarrierList&token=' + static_token,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '';
|
||||
for(var error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error !== 'indexOf')
|
||||
errors += jsonData.errors[error] + "\n";
|
||||
alert(errors);
|
||||
}
|
||||
else
|
||||
updateCarrierList(jsonData);
|
||||
$('#opc_delivery_methods-overlay').fadeOut('slow');
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '';
|
||||
for(var error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error !== 'indexOf')
|
||||
errors += jsonData.errors[error] + "\n";
|
||||
alert(errors);
|
||||
}
|
||||
else
|
||||
updateCarrierList(jsonData);
|
||||
$('#opc_delivery_methods-overlay').fadeOut('slow');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user