我想用产品(简单)价格添加额外的价格,我试图在自定义属性的帮助下做到这一点。我添加了一个自定义属性“保证金价格”,我想将此自定义属性值(保证金价格)与模板文件中产品的基本价格相加。
我每 5 分钟通过 cron 作业更新所有产品价格,这就是为什么我认为我必须通过这种方式将保证金价格与基本产品价格相加。
我在产品列表页面和产品视图页面中成功添加了它,但是如何在购物车和单页结帐中添加此保证金价格与基本价格有问题?
这是产品列表页面上的代码,产品详细信息页面的代码在 magento 1.6.x 中对我来说很好。
$regularPrice = number_format($_product->getFinalPrice(), 2);
//echo $regularPrice = $this->getPriceHtml($_product, true
$priceWithoutComma = str_replace(",", "",$regularPrice);
settype($priceWithoutComma, "float");
$marPrice = $_product->getMarginPrice();
settype($marPrice, "integer");
$finalPrice = $priceWithoutComma + $marPrice;
echo $finalPrice.Mage::app()->getLocale()->currency(Mage::app()->getStore()->
getCurrentCurrencyCode())->getSymbol();
我这样做是正确的,还是我必须改变整个过程?