【问题标题】:magento 1.7 custom options not updating pricemagento 1.7 自定义选项不更新价格
【发布时间】:2014-03-17 17:06:06
【问题描述】:

您好,我有一个带有自定义选项的简单产品,此特定产品的输入类型设置为下拉。

在产品查看页面上,当下拉选择选项更改时,产品的价格不会更改,而是显示为 0.00 英镑。 它会在 js 控制台中引发错误

Uncaught ReferenceError: spConfig is not defined 

这又不是一个可配置的产品。如果我必须添加到购物车并继续结帐,则会从自定义选项中添加值。

我知道这是一个 javascript 问题,我也知道它在 js/varien/product.js 下

但我不知道在哪里进行更改或进行哪些更改。

非常感谢

【问题讨论】:

    标签: javascript php magento options


    【解决方案1】:

    您的两个问题没有直接关系。我们在这里遇到了同样的问题——我假设您使用的是“有机互联网”模块 (http://www.magentocommerce.com/magento-connect/simple-configurable-products.html)。未捕获的引用错误可以通过在运行函数之前检查对象的存在来解决。 (spConfig 对象只存在于可配置的产品页面上。)

    在 /skin/frontent/base/default/js/scp_product_extension.js 中像这样包装最后一个函数:

    if (typeof spConfig != "undefined") {
    
        //SCP: Forces price labels to be updated on load
        //so that first select shows ranges from the start
        document.observe("dom:loaded", function() {
            //Really only needs to be the first element that has configureElement set on it,
            //rather than all.
            $('product_addtocart_form').getElements().each(function(el) {
                if(el.type == 'select-one') {
                    if(el.options && (el.options.length > 1)) {
                        el.options[0].selected = true;
                        spConfig.reloadOptionLabels(el);
                    }
                }
            });
        });
    };
    

    与 0.00 定价相关的实际问题是由于该模块将产品页面上的产品选项 HTML 和 JS 替换为在从下拉菜单中获取选项价格时不会返回有效响应的元素。到目前为止,我们似乎已经通过防止模块以这种方式覆盖来解决这个问题。我不确定这是否是一个完整的修复,我们仍在测试..

    在 /app/design/frontent/base/default/layout/simpleconfigurableproducts.xml 中,注释掉 - 或删除 scpwrapper 和 scpoptions 模板:

      <!--<reference name="product.info.options.wrapper">
            <action method="setTemplate"><template>catalog/product/view/options/scpwrapper.phtml</template></action>
        </reference>
    
        <reference name="product.info.options">
            <action method="setTemplate"><template>catalog/product/view/scpoptions.phtml</template></action>
        </reference>-->
    

    如果我们发现更多信息/问题,将努力更新这篇文章。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-07
      • 1970-01-01
      • 2012-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-25
      • 2012-09-14
      相关资源
      最近更新 更多