opConfig.reloadPrice()的路径在哪里;在magento

时间:2011-09-02 12:53:45

标签: magento

我需要自定义函数opConfig.reloadPrice();在magento。

谁能告诉我该功能在哪里找到?

此功能在产品详细信息页面上的自定义属性下拉列表中执行。

由于我需要更改特价计算,我想需要自定义此功能。

3 个答案:

答案 0 :(得分:4)

此方法可在以下文件中找到:

grep 'reloadPrice:' . -rsn
./js/varien/configurable.js:271:    reloadPrice: function()
./js/varien/product.js:463:    reloadPrice: function()
./skin/frontend/base/default/js/bundle.js:83:    reloadPrice: function()

答案 1 :(得分:3)

对于更改自定义选项值,您应该更改为js / varient / product.js

并在该页面中找到,重新加载:function()

在更改事件时的函数调用。

祝你好运

答案 2 :(得分:0)

我还有一个问题就是必须在这个上更改Magento的默认行为。我在我的项目中包含了jQuery,我最终通过首先删除Magento的默认行为来找出它,而不是在calculatePrice上调用我的calculatePrices() - 函数:

$j('#select_20, #select_21').removeAttr('onchange').change(function(){
    calculatePrices();
});

现在,在这个calculatePrices() - 函数中,除了一些其他逻辑之外,我还包含了这个来改变价格:

function calculatePrices()
{
    var price = 0;

    // some logic with custom options, not interesting for this question...

    // Change the price according to the options:
    $j('#select_20, #select_21').each(function(){
        var selectId = this.id.replace('select_', '');
        var options = opConfig.config[selectId][this.value];
        if(options.type == 'fixed') {
            price += options.priceValue;
        } else {
            // percentual change:
            price += price * (options.priceValue/100);
        }
    });

    // Use Magento Objects to set these prices:
    optionsPrice.changePrice('bundle', price);
    optionsPrice.reload();
}