[英]Is it possible to change the price in the shopping cart in magento?
我已经修改了\\ magento \\ js \\ varien \\ product.js下的功能,以满足客户的要求。 它工作正常,由于我们数据库中的用户信息,因此可以享受折扣。
但是,当客户将商品添加到购物车时,此示例中仅显示原始价格549.47美元。
如何将折扣价插入单价和小计部分? 为此,我应该修改哪个文件?
这是我的javascript代码(\\ magento \\ js \\ varien \\ product.js)的一部分,它们会生成折扣价:
var subPrice = 0; //is the price inside the option
var subPriceincludeTax = 0;
var discountRate = discountRateUrl; //discount base on database
var price = priceUrl;//get the product price
var discountedPrice = price*discountRate; // price * ourdiscount
//var discountedSubPrice = subPrice*((100-test)/100); // custom option addition price * ourdiscounted prices
//console.log(discountedPrice); //display the prices as int
//console.log(discountedSubPrice);
//console.log(test);
Object.values(this.customPrices).each(function(el){
if (el.excludeTax && el.includeTax) {
subPrice += parseFloat(el.excludeTax); // use the var factor && this will affect the price when changing option *important
subPriceincludeTax += parseFloat(el.includeTax);
} else {
subPrice += parseFloat(el.price);
subPriceincludeTax += parseFloat(el.price);
}
var finalprice = (subPrice*discountRate+discountedPrice);//checking if getting the php
var fomattedprice = finalprice.toFixed(2); //Convert a number into a string, keeping only two decimals
console.log(finalprice); //tester of the final prices
console.log(discountRate);//tester discount rate in string
document.getElementById("finalprice").innerHTML = "<small>Your price is </small>"+ "$" + fomattedprice + "*" +"<br/><small><em>*Discount will be applied during check out</em></small>";
});
您可以忽略这些代码,我只想知道应该在哪里传递document.getElementById("finalprice");
结果以显示折扣价。
如果有不清楚的地方,请发表评论,也可以随时编辑我的问题。
提前致谢。
您需要修改
前端/默认/ your_theme /模板/结算/项目/ default.phtml
该文件负责在购物车中显示产品及其信息。 您可以在此处进行更改以查看所需的输出。
希望这会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.