Prestashop购物车节省金额

时间:2015-01-25 17:16:20

标签: prestashop cart

我在Prestashop 1.6.0.9上,我想在购物车页面上添加一个块:“保存金额”,就在“总计”下方。 我使用特定的价格,我想向客户展示他们节省了多少钱。 我怎样才能做到这一点 ? 我想我必须使用cart-summary.js文件。

// Block cart
$('#cart_block_shipping_cost').show();
$('#cart_block_shipping_cost').next().show();
if (json.total_shipping > 0)
{
    if (priceDisplayMethod !== 0)
    {
        $('#cart_block_shipping_cost').html(formatCurrency(json.total_shipping_tax_exc, currencyFormat, currencySign, currencyBlank));
        $('#cart_block_wrapping_cost').html(formatCurrency(json.total_wrapping_tax_exc, currencyFormat, currencySign, currencyBlank));
        $('#cart_block_total').html(formatCurrency(json.total_price_without_tax, currencyFormat, currencySign, currencyBlank));
    }
    else
    {
        $('#cart_block_shipping_cost').html(formatCurrency(json.total_shipping, currencyFormat, currencySign, currencyBlank));
        $('#cart_block_wrapping_cost').html(formatCurrency(json.total_wrapping, currencyFormat, currencySign, currencyBlank));
        $('#cart_block_total').html(formatCurrency(json.total_price, currencyFormat, currencySign, currencyBlank));
    }
}
else
{
    if (json.carrier.id == null)
    {
        $('#cart_block_shipping_cost').hide();
        $('#cart_block_shipping_cost').next().hide();
    }
}

$('#cart_block_tax_cost').html(formatCurrency(json.total_tax, currencyFormat, currencySign, currencyBlank));
$('.ajax_cart_quantity').html(nbrProducts);

// Cart summary
$('#summary_products_quantity').html(nbrProducts + ' ' + (nbrProducts > 1 ? txtProducts : txtProduct));
if (priceDisplayMethod !== 0)
    $('#total_product').html(formatCurrency(json.total_products, currencyFormat, currencySign, currencyBlank));
else
    $('#total_product').html(formatCurrency(json.total_products_wt, currencyFormat, currencySign, currencyBlank));
$('#total_price').html(formatCurrency(json.total_price, currencyFormat, currencySign, currencyBlank));
$('#total_price_without_tax').html(formatCurrency(json.total_price_without_tax, currencyFormat, currencySign, currencyBlank));
$('#total_tax').html(formatCurrency(json.total_tax, currencyFormat, currencySign, currencyBlank));

问题是我有变量total_price(有折扣)但没有折扣的total_price。 如何在不折扣的情况下添加total_price?

1 个答案:

答案 0 :(得分:0)

检查此主题: https://www.prestashop.com/forums/topic/267756-display-total-discount-in-cart-summary-solved/

特别是#20: https://www.prestashop.com/forums/topic/267756-display-total-discount-in-cart-summary-solved/#entry1348278

作者:来自prestashop.com的Gowtham

  

在shopping-cart.js

中添加变量初始化574左右
var total_disc =0;
var price_disc =0;
     

在shopping-cart.js

的第652行附近添加以下代码
total_disc +=(product_list[i].price_without_quantity_discount*product_list[i].quantity_without_customization
     

- product_list [i] .price * product_list [i] .quantity_without_customization);       price_disc =((product_list [i] .price_without_quantity_discount - product_list [i] .price   )*所属类别[I] .quantity_without_customization);       $(' #price_disc _' + key_for_blockcart).html(formatCurrency(price_disc,currencyFormat,currencySign,currencyBlank));

}

$('#total_discount_price').html(formatCurrency(total_disc ,currencyFormat, currencySign, currencyBlank));
     

使用total_discount_price作为shopping-cart.tpl中的ID以获得总折扣   并使用

price_disc_{$product.id_product}_{$product.id_product_attribute}{if
     

$ quantityDisplayed>   0} nocustom {/如果} {$ product.id_address_delivery | INTVAL} {如果   !空($ product.gift)} _ {礼品/如果}

     

作为产品折扣的shopping-cart-product-line.tpl中的ID。该   上面显示的代码是js中key_for_blockcart的表示。