【问题标题】:Replace Price Difference with Actual Price in Magento Configurable Product Options 1.9在 Magento 可配置产品选项 1.9 中用实际价格替换价格差异
【发布时间】:2014-11-17 08:49:23
【问题描述】:

配置产品:

基本价格:Rs.1000

尺寸:小 - 1500 尺寸:中 - 2000

不是以底价递增,而是想将其替换为主要价格

检查了一些解决方案,但 Magento 1.9 版没有任何效果

谢谢你

【问题讨论】:

标签: magento


【解决方案1】:

这是由 javascript 执行的。需要修改js/varien/configurable.js中的getOptionLabel方法

该方法的前几行如下所示:

getOptionLabel: function(option, price){
    var price = parseFloat(price);

您需要将其更改为:

getOptionLabel: function(option, price){
    var basePrice = parseFloat(this.config.basePrice);
    // 'price' as passed is the RELATIVE DIFFERENCE. We won't use it.
    //  The ABSOLUTE DIFFERENCE is in option.price (and option.oldPrice)
    var absoluteDifference = parseFloat(option.price);
    var absoluteFinalPrice = basePrice + absoluteDifference;
    // var price = parseFloat(price);
    var price = absoluteFinalPrice;

要删除选项中的 + 和 - 符号,请找到对 this.formatPrice 函数的调用,并在每次调用中将第二个参数更改为 false。

就像这样:

if(price){
        if (this.taxConfig.showBothPrices) {
            str+= ' ' + this.formatPrice(excl, false) + ' (' + this.formatPrice(price, false) + ' ' + this.taxConfig.inclTaxTitle + ')';
        } else {
            str+= ' ' + this.formatPrice(price, false);
        }

请记住,如果您对核心 magento 文件进行了更改,那么下次升级 Magento 时,您可能会丢失所做的更改。最好创建另一个文件,如 js/varien/custom_configurable.js 或您喜欢的任何名称,并在您使用的任何主题的配置文件 (product.xml) 中调用它。

就是这样。

注意:此方法未在 Magento >1.7 版本上测试

【讨论】:

  • 您是否更改了正确的文件并刷新了 magento 缓存?
猜你喜欢
  • 2011-09-07
  • 1970-01-01
  • 2013-11-03
  • 1970-01-01
  • 2013-05-18
  • 2014-06-13
  • 1970-01-01
  • 2013-04-20
  • 2013-01-15
相关资源
最近更新 更多