[-] FO : #PSTEST-990 - Fix bug with bad ajax return on adding product to the cart with a new cart reduction applyed
This commit is contained in:
1 parent
4775bc7e79
commit
70c4cc943e
6 files changed
+111
-52
No files matched your search
@@ -114,7 +114,7 @@ class CartControllerCore extends FrontController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$removed = CartRule::autoRemoveFromCart();
|
$removed = CartRule::autoRemoveFromCart();
|
||||||
if (count($removed))
|
if (count($removed) && (int)Tools::getValue('allow_refresh'))
|
||||||
$this->ajax_refresh = true;
|
$this->ajax_refresh = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,14 +232,14 @@ class CartControllerCore extends FrontController
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$cart_rules2 = $this->context->cart->getCartRules();
|
$cart_rules2 = $this->context->cart->getCartRules();
|
||||||
if (count($cart_rules2) != count($cart_rules))
|
if (count($cart_rules2) != count($cart_rules) && (int)Tools::getValue('allow_refresh'))
|
||||||
$this->ajax_refresh = true;
|
$this->ajax_refresh = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$removed = CartRule::autoRemoveFromCart();
|
$removed = CartRule::autoRemoveFromCart();
|
||||||
if (count($removed))
|
if (count($removed) && (int)Tools::getValue('allow_refresh'))
|
||||||
$this->ajax_refresh = true;
|
$this->ajax_refresh = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -366,30 +366,29 @@ var ajaxCart = {
|
|||||||
|
|
||||||
//refresh display of vouchers (needed for vouchers in % of the total)
|
//refresh display of vouchers (needed for vouchers in % of the total)
|
||||||
refreshVouchers : function (jsonData) {
|
refreshVouchers : function (jsonData) {
|
||||||
if (jsonData.discounts = undefined || jsonData.discounts.length == 0)
|
if (typeof(jsonData.discounts) == 'undefined' || jsonData.discounts.length == 0)
|
||||||
$('#vouchers').remove();
|
$('#vouchers').hide();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$('.bloc_cart_voucher').each(function(){
|
$('#vouchers tbody').html('');
|
||||||
var idElmt = $(this).attr('id').replace('bloc_cart_voucher_','');
|
|
||||||
var toDelete = true;
|
for (i=0;i<jsonData.discounts.length;i++)
|
||||||
for (i=0;i<jsonData.discounts.length;i++)
|
{
|
||||||
|
if (parseFloat(jsonData.discounts[i].price_float) > 0)
|
||||||
{
|
{
|
||||||
if (jsonData.discounts[i].id == idElmt && parseFloat(jsonData.discounts[i].price_float) > 0)
|
$('#vouchers tbody').append($(
|
||||||
{
|
'<tr class="bloc_cart_voucher" id="bloc_cart_voucher_'+jsonData.discounts[i].id+'">'
|
||||||
$('#bloc_cart_voucher_' + idElmt + ' td.price').text(jsonData.discounts[i].price);
|
+' <td class="quantity">1x</td>'
|
||||||
toDelete = false;
|
+' <td class="name" title="'+jsonData.discounts[i].description+'">'+jsonData.discounts[i].name+'</td>'
|
||||||
}
|
+' <td class="price">-'+jsonData.discounts[i].price+'</td>'
|
||||||
|
+' <td class="delete"><a class="delete_voucher" href="'+jsonData.discounts[i].link+'" title="'+delete_txt+'"><img src="'+img_dir+'icon/delete.gif" alt="'+delete_txt+'" class="icon" /></a></td>'
|
||||||
|
+'</tr>'
|
||||||
|
));
|
||||||
}
|
}
|
||||||
if (toDelete)
|
}
|
||||||
{
|
|
||||||
$('#bloc_cart_voucher_' + idElmt).fadeTo('fast', 0, function(){
|
|
||||||
$(this).remove();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
$('#vouchers').show();
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -629,18 +628,18 @@ var ajaxCart = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function HoverWatcher(selector){
|
function HoverWatcher(selector){
|
||||||
this.hovering = false;
|
this.hovering = false;
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.isHoveringOver = function() {
|
this.isHoveringOver = function() {
|
||||||
return self.hovering;
|
return self.hovering;
|
||||||
}
|
}
|
||||||
|
|
||||||
$(selector).hover(function() {
|
$(selector).hover(function() {
|
||||||
self.hovering = true;
|
self.hovering = true;
|
||||||
}, function() {
|
}, function() {
|
||||||
self.hovering = false;
|
self.hovering = false;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//when document is loaded...
|
//when document is loaded...
|
||||||
@@ -675,5 +674,18 @@ $(document).ready(function(){
|
|||||||
$("#cart_block").stop(true, true).slideUp(450);
|
$("#cart_block").stop(true, true).slideUp(450);
|
||||||
}, 200);
|
}, 200);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('.delete_voucher').live('click', function() {
|
||||||
|
$.ajax({url:$(this).attr('href')});
|
||||||
|
$(this).parent().parent().remove();
|
||||||
|
if ($('body').attr('id') == 'order' || $('body').attr('id') == 'order-opc')
|
||||||
|
{
|
||||||
|
if (typeof(updateAddressSelection) != 'undefined')
|
||||||
|
updateAddressSelection();
|
||||||
|
else
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@
|
|||||||
"name": "{$discount.name|cat:' : '|cat:$discount.description|truncate:18:'...'|addslashes|replace:'\\\'':'\''}",
|
"name": "{$discount.name|cat:' : '|cat:$discount.description|truncate:18:'...'|addslashes|replace:'\\\'':'\''}",
|
||||||
"description": "{$discount.description|addslashes|replace:'\\\'':'\''}",
|
"description": "{$discount.description|addslashes|replace:'\\\'':'\''}",
|
||||||
"nameDescription": "{$discount.name|cat:' : '|cat:$discount.description|truncate:18:'...'|addslashes|replace:'\\\'':'\''}",
|
"nameDescription": "{$discount.name|cat:' : '|cat:$discount.description|truncate:18:'...'|addslashes|replace:'\\\'':'\''}",
|
||||||
"link": "{$link->getPageLink('order', true, NULL, "deleteDiscount={$discount.id_discount}")}",
|
"link": "{$link->getPageLink("$order_process", true, NULL, "deleteDiscount={$discount.id_discount}")}",
|
||||||
"price": "{if $priceDisplay == 1}{convertPrice|html_entity_decode:2:'UTF-8' price=$discount.value_tax_exc}{else}{convertPrice|html_entity_decode:2:'UTF-8' price=$discount.value_real}{/if}",
|
"price": "{if $priceDisplay == 1}{convertPrice|html_entity_decode:2:'UTF-8' price=$discount.value_tax_exc}{else}{convertPrice|html_entity_decode:2:'UTF-8' price=$discount.value_real}{/if}",
|
||||||
"price_float": "{if $priceDisplay == 1}{$discount.value_tax_exc}{else}{$discount.value_real}{/if}"
|
"price_float": "{if $priceDisplay == 1}{$discount.value_tax_exc}{else}{$discount.value_real}{/if}"
|
||||||
{rdelim}
|
{rdelim}
|
||||||
|
|||||||
@@ -106,6 +106,9 @@
|
|||||||
min-width:18px
|
min-width:18px
|
||||||
}
|
}
|
||||||
#cart_block table#vouchers tr td.delete{
|
#cart_block table#vouchers tr td.delete{
|
||||||
|
padding-left: 0;
|
||||||
|
padding-right: 0;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
|
width: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,6 +34,8 @@ var customizationIdMessage = '{l s='Customization #' mod='blockcart' js=1}';
|
|||||||
var removingLinkText = '{l s='remove this product from my cart' mod='blockcart' js=1}';
|
var removingLinkText = '{l s='remove this product from my cart' mod='blockcart' js=1}';
|
||||||
var freeShippingTranslation = '<b>{l s='Free shipping!' mod='blockcart' js=1}</b>';
|
var freeShippingTranslation = '<b>{l s='Free shipping!' mod='blockcart' js=1}</b>';
|
||||||
var freeProductTranslation = '<b>{l s='Free!' mod='blockcart' js=1}</b>';
|
var freeProductTranslation = '<b>{l s='Free!' mod='blockcart' js=1}</b>';
|
||||||
|
var delete_txt = '{l s='Delete' mod='blockcart'}';
|
||||||
|
var img_dir = '{$img_dir}';
|
||||||
</script>
|
</script>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
@@ -67,7 +69,7 @@ var freeProductTranslation = '<b>{l s='Free!' mod='blockcart' js=1}</b>';
|
|||||||
<a class="cart_block_product_name" href="{$link->getProductLink($product, $product.link_rewrite, $product.category, null, null, $product.id_shop, $product.id_product_attribute)}" title="{$product.name|escape:html:'UTF-8'}">
|
<a class="cart_block_product_name" href="{$link->getProductLink($product, $product.link_rewrite, $product.category, null, null, $product.id_shop, $product.id_product_attribute)}" title="{$product.name|escape:html:'UTF-8'}">
|
||||||
{$product.name|truncate:13:'...'|escape:html:'UTF-8'}</a>
|
{$product.name|truncate:13:'...'|escape:html:'UTF-8'}</a>
|
||||||
<span class="remove_link">{if !isset($customizedDatas.$productId.$productAttributeId)}<a rel="nofollow" class="ajax_cart_block_remove_link" href="{$link->getPageLink('cart', true, NULL, "delete&id_product={$product.id_product}&ipa={$product.id_product_attribute}&id_address_delivery={$product.id_address_delivery}&token={$static_token}")}" title="{l s='remove this product from my cart' mod='blockcart'}"> </a>{/if}</span>
|
<span class="remove_link">{if !isset($customizedDatas.$productId.$productAttributeId)}<a rel="nofollow" class="ajax_cart_block_remove_link" href="{$link->getPageLink('cart', true, NULL, "delete&id_product={$product.id_product}&ipa={$product.id_product_attribute}&id_address_delivery={$product.id_address_delivery}&token={$static_token}")}" title="{l s='remove this product from my cart' mod='blockcart'}"> </a>{/if}</span>
|
||||||
<span class="price">{$product.total}
|
<span class="price">
|
||||||
{if $product.total > 0}
|
{if $product.total > 0}
|
||||||
{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice p="`$product.total`"}{else}{displayWtPrice p="`$product.total_wt`"}{/if}
|
{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice p="`$product.total`"}{else}{displayWtPrice p="`$product.total_wt`"}{/if}
|
||||||
{else}
|
{else}
|
||||||
@@ -105,21 +107,22 @@ var freeProductTranslation = '<b>{l s='Free!' mod='blockcart' js=1}</b>';
|
|||||||
{/if}
|
{/if}
|
||||||
<p {if $products}class="hidden"{/if} id="cart_block_no_products">{l s='No products' mod='blockcart'}</p>
|
<p {if $products}class="hidden"{/if} id="cart_block_no_products">{l s='No products' mod='blockcart'}</p>
|
||||||
|
|
||||||
{if $discounts|@count > 0}<table id="vouchers">
|
<table id="vouchers">
|
||||||
<tbody>
|
<tbody>
|
||||||
{foreach from=$discounts item=discount}
|
{if $discounts|@count > 0}
|
||||||
{if $discount.value_real > 0}
|
{foreach from=$discounts item=discount}
|
||||||
<tr class="bloc_cart_voucher" id="bloc_cart_voucher_{$discount.id_discount}">
|
{if $discount.value_real > 0}
|
||||||
<td class="quantity">1x</td>
|
<tr class="bloc_cart_voucher" id="bloc_cart_voucher_{$discount.id_discount}">
|
||||||
<td class="name" title="{$discount.description}">{$discount.name|cat:' : '|cat:$discount.description|truncate:18:'...'|escape:'htmlall':'UTF-8'}</td>
|
<td class="quantity">1x</td>
|
||||||
<td class="price">-{if $priceDisplay == 1}{convertPrice price=$discount.value_tax_exc}{else}{convertPrice price=$discount.value_real}{/if}</td>
|
<td class="name" title="{$discount.description}">{$discount.name|cat:' : '|cat:$discount.description|truncate:18:'...'|escape:'htmlall':'UTF-8'}</td>
|
||||||
<td class="delete"><a href="{$link->getPageLink('$order_process.php', true)}?deleteDiscount={$discount.id_discount}" title="{l s='Delete'}"><img src="{$img_dir}icon/delete.gif" alt="{l s='Delete'}" class="icon" /></a></td>
|
<td class="price">-{if $priceDisplay == 1}{convertPrice price=$discount.value_tax_exc}{else}{convertPrice price=$discount.value_real}{/if}</td>
|
||||||
</tr>
|
<td class="delete"><a class="delete_voucher" href="{$link->getPageLink('$order_process.php', true)}?deleteDiscount={$discount.id_discount}" title="{l s='Delete' mod='blockcart'}"><img src="{$img_dir}icon/delete.gif" alt="{l s='Delete' mod='blockcart'}" class="icon" /></a></td>
|
||||||
|
</tr>
|
||||||
|
{/if}
|
||||||
|
{/foreach}
|
||||||
{/if}
|
{/if}
|
||||||
{/foreach}
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{/if}
|
|
||||||
|
|
||||||
<p id="cart-prices">
|
<p id="cart-prices">
|
||||||
<span id="cart_block_shipping_cost" class="price ajax_cart_shipping_cost">{$shipping_cost}</span>
|
<span id="cart_block_shipping_cost" class="price ajax_cart_shipping_cost">{$shipping_cost}</span>
|
||||||
|
|||||||
@@ -95,7 +95,8 @@ function changeAddressDelivery(obj)
|
|||||||
+'&id_product_attribute='+id_product_attribute
|
+'&id_product_attribute='+id_product_attribute
|
||||||
+'&old_id_address_delivery='+old_id_address_delivery
|
+'&old_id_address_delivery='+old_id_address_delivery
|
||||||
+'&new_id_address_delivery='+new_id_address_delivery
|
+'&new_id_address_delivery='+new_id_address_delivery
|
||||||
+'&token='+static_token,
|
+'&token='+static_token
|
||||||
|
+'&allow_refresh=1',
|
||||||
success: function(jsonData)
|
success: function(jsonData)
|
||||||
{
|
{
|
||||||
// The product exist
|
// The product exist
|
||||||
@@ -154,7 +155,14 @@ function changeAddressDelivery(obj)
|
|||||||
cache: false,
|
cache: false,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
context: obj,
|
context: obj,
|
||||||
data: 'controller=cart&ajax=true&duplicate&summary&id_product='+id_product+'&id_product_attribute='+id_product_attribute+'&id_address_delivery='+old_id_address_delivery+'&new_id_address_delivery='+id_address_delivery+'&token='+static_token ,
|
data: 'controller=cart'
|
||||||
|
+'&ajax=true&duplicate&summary'
|
||||||
|
+'&id_product='+id_product
|
||||||
|
+'&id_product_attribute='+id_product_attribute
|
||||||
|
+'&id_address_delivery='+old_id_address_delivery
|
||||||
|
+'&new_id_address_delivery='+id_address_delivery
|
||||||
|
+'&token='+static_token
|
||||||
|
+'&allow_refresh=1',
|
||||||
success: function(jsonData)
|
success: function(jsonData)
|
||||||
{
|
{
|
||||||
if (jsonData.error)
|
if (jsonData.error)
|
||||||
@@ -250,7 +258,13 @@ function deleteProductFromSummary(id)
|
|||||||
async: true,
|
async: true,
|
||||||
cache: false,
|
cache: false,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: 'controller=cart&ajax=true&delete&summary&id_product='+productId+'&ipa='+productAttributeId+'&id_address_delivery='+id_address_delivery+ ( (customizationId != 0) ? '&id_customization='+customizationId : '') + '&token=' + static_token ,
|
data: 'controller=cart'
|
||||||
|
+'&ajax=true&delete&summary'
|
||||||
|
+'&id_product='+productId
|
||||||
|
+'&ipa='+productAttributeId
|
||||||
|
+'&id_address_delivery='+id_address_delivery+ ( (customizationId != 0) ? '&id_customization='+customizationId : '')
|
||||||
|
+'&token=' + static_token
|
||||||
|
+'&allow_refresh=1',
|
||||||
success: function(jsonData)
|
success: function(jsonData)
|
||||||
{
|
{
|
||||||
if (jsonData.hasError)
|
if (jsonData.hasError)
|
||||||
@@ -331,7 +345,17 @@ function upQuantity(id, qty)
|
|||||||
async: true,
|
async: true,
|
||||||
cache: false,
|
cache: false,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: 'controller=cart&ajax=true&add&getproductprice&summary&id_product='+productId+'&ipa='+productAttributeId+'&id_address_delivery='+id_address_delivery + ( (customizationId != 0) ? '&id_customization='+customizationId : '') + '&qty='+qty+'&token=' + static_token ,
|
data: 'controller=cart'
|
||||||
|
+'&ajax=true'
|
||||||
|
+'&add'
|
||||||
|
+'&getproductprice'
|
||||||
|
+'&summary'
|
||||||
|
+'&id_product='+productId
|
||||||
|
+'&ipa='+productAttributeId
|
||||||
|
+'&id_address_delivery='+id_address_delivery + ( (customizationId != 0) ? '&id_customization='+customizationId : '')
|
||||||
|
+'&qty='+qty
|
||||||
|
+'&token='+static_token
|
||||||
|
+'&allow_refresh=1',
|
||||||
success: function(jsonData)
|
success: function(jsonData)
|
||||||
{
|
{
|
||||||
if (jsonData.hasError)
|
if (jsonData.hasError)
|
||||||
@@ -392,7 +416,18 @@ function downQuantity(id, qty)
|
|||||||
async: true,
|
async: true,
|
||||||
cache: false,
|
cache: false,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: 'controller=cart&ajax=true&add&getproductprice&summary&id_product='+productId+'&ipa='+productAttributeId+'&id_address_delivery='+id_address_delivery+'&op=down' + ( (customizationId != 0) ? '&id_customization='+customizationId : '') + '&qty='+qty+'&token=' + static_token ,
|
data: 'controller=cart'
|
||||||
|
+'&ajax=true'
|
||||||
|
+'&add'
|
||||||
|
+'&getproductprice'
|
||||||
|
+'&summary'
|
||||||
|
+'&id_product='+productId
|
||||||
|
+'&ipa='+productAttributeId
|
||||||
|
+'&id_address_delivery='+id_address_delivery
|
||||||
|
+'&op=down' + ( (customizationId != 0) ? '&id_customization='+customizationId : '')
|
||||||
|
+'&qty='+qty
|
||||||
|
+'&token='+static_token
|
||||||
|
+'&allow_refresh=1',
|
||||||
success: function(jsonData)
|
success: function(jsonData)
|
||||||
{
|
{
|
||||||
if (jsonData.hasError)
|
if (jsonData.hasError)
|
||||||
@@ -651,7 +686,8 @@ $(document).ready(function() {
|
|||||||
cache: false,
|
cache: false,
|
||||||
data: 'controller=cart&ajax=true&allowSeperatedPackage&value='
|
data: 'controller=cart&ajax=true&allowSeperatedPackage&value='
|
||||||
+($(this).attr('checked') ? '1' : '0')
|
+($(this).attr('checked') ? '1' : '0')
|
||||||
+'&token='+static_token,
|
+'&token='+static_token
|
||||||
|
+'&allow_refresh=1',
|
||||||
success: function(jsonData)
|
success: function(jsonData)
|
||||||
{
|
{
|
||||||
if (typeof(getCarrierListAndUpdate) != 'undefined')
|
if (typeof(getCarrierListAndUpdate) != 'undefined')
|
||||||
@@ -687,7 +723,12 @@ function updateExtraCarrier(id_delivery_option, id_address)
|
|||||||
async: true,
|
async: true,
|
||||||
cache: false,
|
cache: false,
|
||||||
dataType : "json",
|
dataType : "json",
|
||||||
data: 'ajax=true&method=updateExtraCarrier&id_address='+id_address+'&id_delivery_option='+id_delivery_option+'&token=' + static_token,
|
data: 'ajax=true'
|
||||||
|
+'&method=updateExtraCarrier'
|
||||||
|
+'&id_address='+id_address
|
||||||
|
+'&id_delivery_option='+id_delivery_option
|
||||||
|
+'&token='+static_token
|
||||||
|
+'&allow_refresh=1',
|
||||||
success: function(jsonData)
|
success: function(jsonData)
|
||||||
{
|
{
|
||||||
$('#HOOK_EXTRACARRIER_'+id_address).html(jsonData['content']);
|
$('#HOOK_EXTRACARRIER_'+id_address).html(jsonData['content']);
|
||||||
|
|||||||
Reference in new issue
Block a user