9

您好,我正在使用 magento 1.7。我有可配置产品和简单产品都有自定义选项...我想删除选项旁边的 +$10.00 示例:自定义选项:大 +$5.00 我希望它显示为大...我仍然希望价格在产品的查看页面上更新。我尝试编辑 js/varien/product.js 注释掉 str+ 但没有用

//str+= ' ' + this.formatPrice(excl, true) + ' (' + this.formatPrice(price, true) + ' ' + this.taxConfig.inclTaxTitle + ')';
            } else {
                //str+= ' ' + this.formatPrice(price, true);
            }
        }
        return str;
    },
formatPrice: function(price, showSign){
    var str = '';
    price = parseFloat(price);
    if(showSign){
        if(price<0){
            //str+= '-';
            price = -price;
        }
        else{
            //str+= '+';
        }
4

7 回答 7

7

由于它与 CE 1.8 中的可配置产品有关,因此我一直在研究这个问题几个小时。我的解决方案实际上在 /js/varien/configurable.js 的第 236-258 行。注释掉如下四行,如图:

formatPrice: function(price, showSign){
    var str = '';
    price = parseFloat(price);
    if(showSign){
        if(price<0){
            //str+= '-';
            price = -price;
        }
        else{
            //str+= '+';
        }
    }

    var roundedPrice = (Math.round(price*100)/100).toString();

    if (this.prices && this.prices[roundedPrice]) {
        //str+= this.prices[roundedPrice];
    }
    else {
        //str+= this.priceTemplate.evaluate({price:price.toFixed(2)});
    }
    return str;
},

注释掉上面显示的行的最终效果是下拉列表中给定选项的价格调整消失了。我一直在现场寻找是否有任何意想不到的后果,但还没有看到任何东西。

于 2013-11-21T18:51:20.610 回答
5

使用上面用户“RS”的评论,我能够为我的网站解决这个问题。这是我网站上的屏幕截图,显示修复工作http://tinypic.com/r/5pexz4/5

查找文件

/app/code/core/Mage/Catalog/Block/Product/View/Options/Type/Select.php

转到第 70 - 74 行

$select->addOption(
                $_value->getOptionTypeId(),
                $_value->getTitle() . ' ' . $priceStr . '',
                array('price' => $this->helper('core')->currencyByStore($_value->getPrice(true), $store, false))
            );

从第 72 行删除此代码

. ' ' . $priceStr . ''

或注释掉代码

$_value->getTitle() /*. ' ' . $priceStr . ''*/,

请务必在语句末尾留下“,”。我的代码现在看起来像这样并且工作正常。

$select->addOption(
                $_value->getOptionTypeId(),
                $_value->getTitle() /*. ' ' . $priceStr . ''*/,
                array('price' => $this->helper('core')->currencyByStore($_value->getPrice(true), $store, false))
            );

我希望这对您和其他正在寻找相同解决方案的人有所帮助!

于 2013-05-23T18:48:22.447 回答
5

您需要查看Mage_Catalog_Block_Product_View_Options_Abstract::_formatPrice()[link]

无法使用框架重写此方法。由于使用此方法的显示逻辑可能涉及许多领域,因此我将研究基于 CSS 的解决方案。虽然这可能看起来很老套,但它可能比尝试扩展每个子类来处理您的逻辑更干净。以下内容适用于默认主题:

#product-options-wrapper span.price-notice,
#product-options-wrapper span.price { display:none } 
于 2012-11-20T13:24:58.893 回答
2

将此 JavaScript 添加到template/catalog/product/view.phtml

<script>    
// Override formatting in "js/varien/configurable.js"
Product.Config.prototype.formatPrice = Product.Config.prototype.formatPrice.wrap(
      function(parentMethod, price, showSign){ return ''; }
);
</script>

或者,您可以使用上述代码创建一个新的 JS 文件,并通过 local.xml 将其包含在产品详细信息和产品评论页面的块中。

于 2015-05-19T03:18:56.890 回答
1

从@RS 看:/app/code/core/Mage/Catalog/Block/Product/View/Options/Type/Select.php [L 65-75]

        foreach ($_option->getValues() as $_value) {
            $priceStr = $this->_formatPrice(array(
                'is_percent' => ($_value->getPriceType() == 'percent') ? true : false,
                'pricing_value' => $_value->getPrice(true)
            ), false);
            $select->addOption(
                $_value->getOptionTypeId(),
                $_value->getTitle() . ' ' . $priceStr . '',
                array('price' => $this->helper('core')->currencyByStore($_value->getPrice(true), $store, false))
            );
        }

我无法对此进行测试,但是如果您在获取标题后删除所有内容,它应该做您想做的事情, 您不会想在核心文件中进行这样的编辑 测试它很好。

        foreach ($_option->getValues() as $_value) {
            $priceStr = $this->_formatPrice(array(
                'is_percent' => ($_value->getPriceType() == 'percent') ? true : false,
                'pricing_value' => $_value->getPrice(true)
            ), false);
            $select->addOption(
                $_value->getOptionTypeId(),
                $_value->getTitle()
            );
        }

我会研究将其扩展Mage_Catalog_Block_Product_View_Options_Type_Select或复制出核心文件的最佳实践。

于 2012-11-20T13:14:04.730 回答
0

STEP 1 app/code/core/Mage/Catalog/Block/Product/View/Type/Configurable.php

更改此行

'template'  => str_replace('%s', '#{price}' $store->getCurrentCurrency()->getOutputFormat()),

'template'          => Mage::helper('catalog')->__(''),

STEP 2 js/varien/product.js 改变这个函数

formatPrice: function(price, showSign){ 
    var str = ''; 
    price = parseFloat(price); 
    if(showSign){ 
    if(price<0){ 
    str+= '-'; 
    price = -price; 
    } 
    else{ 
    str+= '+'; 
    } 
} 

格式价格:函数(价格,显示符号){

var str = ''; 
price = parseFloat(price); 
if(showSign){ 
if(price < 0){ 
str+= ''; 
price = -price; 
} 
else{ 
str+= ''; 
} 

} STEP 3 js/varien/configurable.js.js 改变这个函数

formatPrice: function(price, showSign){ 
    var str = ''; 
    price = parseFloat(price); 
    if(showSign){ 
    if(price<0){ 
    str+= '-'; 
    price = -price; 
    } 
    else{ 
    str+= '+'; 
    } 
} 

格式价格:函数(价格,显示符号){

var str = ''; 
price = parseFloat(price); 
if(showSign){ 
if(price < 0){ 
str+= ''; 
price = -price; 
} 
else{ 
str+= ''; 
} 

} 这对我来说很有效。我通过链接http://ram-magento.blogspot.in/2011/10/remove-or-price-value-in-drop-down-in.html得到了答案

于 2014-10-18T17:09:32.250 回答
0

它对我有用 setp 01:转到 app/design/frontend/your_package/your_theme/template/catalog/product/view/type/options/

setp 02:打开可配置的.phtml 文件

setp 03 : 过去在页面顶部的以下 javascript

<script type="text/javascript">
jQuery(document).ready(function(e) {
    checkoptions();

    jQuery("select.super-attribute-select").change(function(){
        checkoptions();
    });
});

function checkoptions(){
    jQuery("select.super-attribute-select option").each(function(){
        var optiontext = jQuery(this).text();
        var addsignpos = optiontext.indexOf('+');
        var subtractsignpos = optiontext.indexOf('-');
        if(addsignpos>0){
            var result = optiontext.substring(0,addsignpos-1);
            jQuery(this).html(result);
        }

        if(subtractsignpos>0){
            var result = optiontext.substring(0,subtractsignpos-1);
            jQuery(this).html(result);
        }
    });
}

原始来源:http ://www.cybernetikz.com/remove-price-configurable-products-dropdown-options-magento/

于 2015-12-20T13:34:43.023 回答