// Fix blockcart removing products
This commit is contained in:
@@ -81,8 +81,10 @@ var ajaxCart = {
|
|||||||
productAttributeId = parseInt(ids[1]);
|
productAttributeId = parseInt(ids[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var idAddressDelivery = $(this).parent().parent().attr('id').match(/.*_\d+_\d+_(\d+)/)[1];
|
||||||
|
|
||||||
// Removing product from the cart
|
// Removing product from the cart
|
||||||
ajaxCart.remove(productId, productAttributeId, customizationId);
|
ajaxCart.remove(productId, productAttributeId, customizationId, idAddressDelivery);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -243,7 +245,7 @@ var ajaxCart = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
//remove a product from the cart via ajax
|
//remove a product from the cart via ajax
|
||||||
remove : function(idProduct, idCombination, customizationId){
|
remove : function(idProduct, idCombination, customizationId, idAddressDelivery){
|
||||||
//send the ajax request to the server
|
//send the ajax request to the server
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
@@ -251,7 +253,7 @@ var ajaxCart = {
|
|||||||
async: true,
|
async: true,
|
||||||
cache: false,
|
cache: false,
|
||||||
dataType : "json",
|
dataType : "json",
|
||||||
data: 'controller=cart&delete=1&id_product=' + idProduct + '&ipa=' + ((idCombination != null && parseInt(idCombination)) ? idCombination : '') + ((customizationId && customizationId != null) ? '&id_customization=' + customizationId : '') + '&token=' + static_token + '&ajax=true',
|
data: 'controller=cart&delete=1&id_product=' + idProduct + '&ipa=' + ((idCombination != null && parseInt(idCombination)) ? idCombination : '') + ((customizationId && customizationId != null) ? '&id_customization=' + customizationId : '') + '&id_address_delivery=' + idAddressDelivery + '&token=' + static_token + '&ajax=true',
|
||||||
success: function(jsonData) {
|
success: function(jsonData) {
|
||||||
ajaxCart.updateCart(jsonData);
|
ajaxCart.updateCart(jsonData);
|
||||||
if ($('body').attr('id') == 'order' || $('body').attr('id') == 'order-opc')
|
if ($('body').attr('id') == 'order' || $('body').attr('id') == 'order-opc')
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
"name": "{$product.name|html_entity_decode:2:'UTF-8'|escape|truncate:15:'...':true}",
|
"name": "{$product.name|html_entity_decode:2:'UTF-8'|escape|truncate:15:'...':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}",
|
"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},
|
"idCombination": {if isset($product.attributes_small)}{$productAttributeId}{else}0{/if},
|
||||||
|
"idAddressDelivery": {if isset($product.id_address_delivery)}{$product.id_address_delivery}{else}0{/if},
|
||||||
{if isset($product.attributes_small)}
|
{if isset($product.attributes_small)}
|
||||||
"hasAttributes": true,
|
"hasAttributes": true,
|
||||||
"attributes": "{$product.attributes_small|addslashes|replace:'\\\'':'\''}",
|
"attributes": "{$product.attributes_small|addslashes|replace:'\\\'':'\''}",
|
||||||
|
|||||||
@@ -94,7 +94,8 @@ class BlockCart extends Module
|
|||||||
'product_total' => Tools::displayPrice($params['cart']->getOrderTotal($useTax, Cart::BOTH_WITHOUT_SHIPPING), $currency),
|
'product_total' => Tools::displayPrice($params['cart']->getOrderTotal($useTax, Cart::BOTH_WITHOUT_SHIPPING), $currency),
|
||||||
'total' => Tools::displayPrice($totalToPay, $currency),
|
'total' => Tools::displayPrice($totalToPay, $currency),
|
||||||
'order_process' => Configuration::get('PS_ORDER_PROCESS_TYPE') ? 'order-opc' : 'order',
|
'order_process' => Configuration::get('PS_ORDER_PROCESS_TYPE') ? 'order-opc' : 'order',
|
||||||
'ajax_allowed' => (int)(Configuration::get('PS_BLOCK_CART_AJAX')) == 1 ? true : false
|
'ajax_allowed' => (int)(Configuration::get('PS_BLOCK_CART_AJAX')) == 1 ? true : false,
|
||||||
|
'static_token' => Tools::getToken(false)
|
||||||
));
|
));
|
||||||
if (sizeof($errors))
|
if (sizeof($errors))
|
||||||
$this->smarty->assign('errors', $errors);
|
$this->smarty->assign('errors', $errors);
|
||||||
|
|||||||
@@ -60,11 +60,11 @@ var removingLinkText = '{l s='remove this product from my cart' mod='blockcart'
|
|||||||
{foreach from=$products item='product' name='myLoop'}
|
{foreach from=$products item='product' name='myLoop'}
|
||||||
{assign var='productId' value=$product.id_product}
|
{assign var='productId' value=$product.id_product}
|
||||||
{assign var='productAttributeId' value=$product.id_product_attribute}
|
{assign var='productAttributeId' value=$product.id_product_attribute}
|
||||||
<dt id="cart_block_product_{$product.id_product}{if $product.id_product_attribute}_{$product.id_product_attribute}{/if}" class="{if $smarty.foreach.myLoop.first}first_item{elseif $smarty.foreach.myLoop.last}last_item{else}item{/if}">
|
<dt id="cart_block_product_{$product.id_product}_{if $product.id_product_attribute}{$product.id_product_attribute}{else}0{/if}_{if $product.id_address_delivery}{$product.id_address_delivery}{else}0{/if}" class="{if $smarty.foreach.myLoop.first}first_item{elseif $smarty.foreach.myLoop.last}last_item{else}item{/if}">
|
||||||
<span class="quantity-formated"><span class="quantity">{$product.cart_quantity}</span>x</span>
|
<span class="quantity-formated"><span class="quantity">{$product.cart_quantity}</span>x</span>
|
||||||
<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}&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">{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice p="`$product.total`"}{else}{displayWtPrice p="`$product.total_wt`"}{/if}</span>
|
<span class="price">{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice p="`$product.total`"}{else}{displayWtPrice p="`$product.total_wt`"}{/if}</span>
|
||||||
</dt>
|
</dt>
|
||||||
{if isset($product.attributes_small)}
|
{if isset($product.attributes_small)}
|
||||||
|
|||||||
Reference in New Issue
Block a user