// Fix blockcart removing products

This commit is contained in:
mDeflotte
2011-12-21 18:09:48 +00:00
parent 91822544dc
commit 34c077fabb
4 changed files with 10 additions and 6 deletions
+5 -3
View File
@@ -81,8 +81,10 @@ var ajaxCart = {
productAttributeId = parseInt(ids[1]);
}
var idAddressDelivery = $(this).parent().parent().attr('id').match(/.*_\d+_\d+_(\d+)/)[1];
// Removing product from the cart
ajaxCart.remove(productId, productAttributeId, customizationId);
ajaxCart.remove(productId, productAttributeId, customizationId, idAddressDelivery);
return false;
});
},
@@ -243,7 +245,7 @@ var ajaxCart = {
},
//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
$.ajax({
type: 'POST',
@@ -251,7 +253,7 @@ var ajaxCart = {
async: true,
cache: false,
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) {
ajaxCart.updateCart(jsonData);
if ($('body').attr('id') == 'order' || $('body').attr('id') == 'order-opc')
+1
View File
@@ -38,6 +38,7 @@
"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}",
"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)}
"hasAttributes": true,
"attributes": "{$product.attributes_small|addslashes|replace:'\\\'':'\''}",
+2 -1
View File
@@ -94,7 +94,8 @@ class BlockCart extends Module
'product_total' => Tools::displayPrice($params['cart']->getOrderTotal($useTax, Cart::BOTH_WITHOUT_SHIPPING), $currency),
'total' => Tools::displayPrice($totalToPay, $currency),
'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))
$this->smarty->assign('errors', $errors);
+2 -2
View File
@@ -60,11 +60,11 @@ var removingLinkText = '{l s='remove this product from my cart' mod='blockcart'
{foreach from=$products item='product' name='myLoop'}
{assign var='productId' value=$product.id_product}
{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>
<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>
<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&amp;id_product={$product.id_product}&amp;ipa={$product.id_product_attribute}&amp;token={$static_token}")}" title="{l s='remove this product from my cart' mod='blockcart'}">&nbsp;</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&amp;id_product={$product.id_product}&amp;ipa={$product.id_product_attribute}&amp;id_address_delivery={$product.id_address_delivery}&amp;token={$static_token}")}" title="{l s='remove this product from my cart' mod='blockcart'}">&nbsp;</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>
</dt>
{if isset($product.attributes_small)}