Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 2
Remove “+£xx” from options on product view (configurable products)
 
ste1986
Jr. Member
 
Total Posts:  13
Joined:  2009-05-06
 

Hi,

I’m trying to remove the price change indicators on the options of my configurable products. The product shows the configurable options as a dropdown box at the moment. So they show as:

“Large +£20.00” and I want it to just show the option name “Large”

I’ve been searching through files all morning and Google isn’t showing anything. Can anyone point me in the right direction?

Thanks in advance,

Stephen

 
Magento Community Magento Community
Magento Community
Magento Community
 
coolshop
Sr. Member
 
Total Posts:  121
Joined:  2009-08-28
 

Ok you need to access the file:

/js/varien/product.js

and look for the following code then comment the line as shown below (//):

var str option.label;
        if(
price){
            
if (this.taxConfig.showBothPrices{
                
//str+= ' ' + this.formatPrice(excl, true) + ' (' + this.formatPrice(price, true) + ' ' + this.taxConfig.inclTaxTitle + ')';
            
else {
                
//str+= ' ' + this.formatPrice(price, true);
            
}
        }
        
return str;
    
},

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

I hope that helps.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Fabriprint
Jr. Member
 
Total Posts:  25
Joined:  2010-02-19
 

It didn´t helped me :( i guess is because mine is a simple product, but is too troublesome to create it as a new configurable product because all products were created as simple products until we found this tool. Is irrelevant the changes i do there on js/varien/product

help?

 
Magento Community Magento Community
Magento Community
Magento Community
 
coolshop
Sr. Member
 
Total Posts:  121
Joined:  2009-08-28
 

Ok there are two types of options. Options on configurable products and options on simple products (called custom options) The solution I posted previously is for configurable products and it does work. May be it may help someone else.

Now to solve the problem on a simple product with custom options, it is a different file that need to change:
/app/code/core/Mage/Catalog/Block/Product/View/Options/Type/Select.php

IMPORTANT: keep in mind this is a core app file and therefore these changes will not be upgrade proof. You may create your own local version of the file and make the changes so in the future any upgrade will be seamless.

For option type Dropdown or Multiple select
Replace this

$select->addOption(
                    
$_value->getOptionTypeId(),
                    
$_value->getTitle() . ' ' $priceStr ''
                
);

with this

$select->addOption(
                    
$_value->getOptionTypeId(),
                    
$_value->getTitle() . ' ' ''
                
);

For option type Dropdown or Multiple select
Replace this

$selectHtml .= '<li>' .
                               
'<input type="'.$type.'" class="'.$class.' '.$require.' product-custom-option" onclick="opConfig.reloadPrice()" name="options['.$_option->getId().']'.$arraySign.'" id="options_'.$_option->getId().'_'.$count.'" value="'.$_value->getOptionTypeId().'" />' .
                               
'<span class="label"><label for="options_'.$_option->getId().'_'.$count.'">'.$_value->getTitle().' '.$priceStr.'</label></span>';

With this

$selectHtml .= '<li>' .
                               
'<input type="'.$type.'" class="'.$class.' '.$require.' product-custom-option" onclick="opConfig.reloadPrice()" name="options['.$_option->getId().']'.$arraySign.'" id="options_'.$_option->getId().'_'.$count.'" value="'.$_value->getOptionTypeId().'" />' .
                               
'<span class="label"><label for="options_'.$_option->getId().'_'.$count.'">'.$_value->getTitle().' '.'</label></span>';

Note that all that is done is remove the reference to $priceStr in the string being displayed
You may also if you like display the price of the option instead of the + or - relative to the simple product price.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Fabriprint
Jr. Member
 
Total Posts:  25
Joined:  2010-02-19
 

Cool, and how do i do that of putting the price? i would love to try that out but i can´t see the changes since i have a problem like i posted here: http://www.magentocommerce.com/boards/viewthread/78033/ and anyone could help me yet :S i´m in a lot of stress to solve this, and i can´t change the .htaccess file using fireFTP, and i have the files of backup of the website if i could known which files i needed to replace maybe i could do the trick :S

coolshop - 19 February 2010 04:16 AM

Ok there are two types of options. Options on configurable products and options on simple products (called custom options) The solution I posted previously is for configurable products and it does work. May be it may help someone else.

Now to solve the problem on a simple product with custom options, it is a different file that need to change:
/app/code/core/Mage/Catalog/Block/Product/View/Options/Type/Select.php

IMPORTANT: keep in mind this is a core app file and therefore these changes will not be upgrade proof. You may create your own local version of the file and make the changes so in the future any upgrade will be seamless.

For option type Dropdown or Multiple select
Replace this

$select->addOption(
                    
$_value->getOptionTypeId(),
                    
$_value->getTitle() . ' ' $priceStr ''
                
);

with this
$select->addOption(
                    
$_value->getOptionTypeId(),
                    
$_value->getTitle() . ' ' ''
                
);

For option type Dropdown or Multiple select
Replace this
$selectHtml .= '<li>' .
                               
'<input type="'.$type.'" class="'.$class.' '.$require.' product-custom-option" onclick="opConfig.reloadPrice()" name="options['.$_option->getId().']'.$arraySign.'" id="options_'.$_option->getId().'_'.$count.'" value="'.$_value->getOptionTypeId().'" />' .
                               
'<span class="label"><label for="options_'.$_option->getId().'_'.$count.'">'.$_value->getTitle().' '.$priceStr.'</label></span>';

With this
$selectHtml .= '<li>' .
                               
'<input type="'.$type.'" class="'.$class.' '.$require.' product-custom-option" onclick="opConfig.reloadPrice()" name="options['.$_option->getId().']'.$arraySign.'" id="options_'.$_option->getId().'_'.$count.'" value="'.$_value->getOptionTypeId().'" />' .
                               
'<span class="label"><label for="options_'.$_option->getId().'_'.$count.'">'.$_value->getTitle().' '.'</label></span>';

Note that all that is done is remove the reference to $priceStr in the string being displayed
You may also if you like display the price of the option instead of the + or - relative to the simple product price.
 
Magento Community Magento Community
Magento Community
Magento Community
 
The Design Bank
Jr. Member
 
Total Posts:  2
Joined:  2009-06-15
 

This code worked really well but it would be a lot nicer to show what the price would be rather than how this option will affect the base price…
I.e Red = £55, Blue = £56 not Red +£1, Blue + £2

please can someone help ?

var str option.label;
        if(
price){
            
if (this.taxConfig.showBothPrices{
                
//str+= \' \' + this.formatPrice(excl, true) + \' (\' + this.formatPrice(price, true) + \' \' + this.taxConfig.inclTaxTitle + \')\';
            
else {
                
//str+= \' \' + this.formatPrice(price, true);
            
}
        }
        
return str;
    
},

    
formatPrice: function(priceshowSign){
        
var str \'\';
        
price parseFloat(price);
        if(
showSign){
            
if(price<0){
                
//str+= \'-\';
                
price = -price;
            
}
            else{
                
//str+= \'+\';
            
}
        }
 
Magento Community Magento Community
Magento Community
Magento Community
 
webcitz
Sr. Member
 
Avatar
Total Posts:  128
Joined:  2008-11-10
Appleton, WI
 

Hey Design Bank,

Look in this file: /app/code/core/Mage/Catalog/Block/Product/View/Options/Abstract.php for:

protected function _formatPrice($value$flag=true)
    
{
        
if ($value['pricing_value'== 0{
            
return '+';
        
}
        $sign 
'';

The “return ‘+’;” is what needs to be changed.

 
Magento Community Magento Community
Magento Community
Magento Community
 
dmibau
Member
 
Total Posts:  72
Joined:  2010-07-12
 
coolshop - 19 February 2010 04:16 AM

IMPORTANT: keep in mind this is a core app file and therefore these changes will not be upgrade proof. You may create your own local version of the file and make the changes so in the future any upgrade will be seamless.

So if I want to override this file
/app/code/core/Mage/Catalog/Block/Product/View/Options/Type/Select.php
I need to create a copy like this
/app/code/local/Mage/Catalog/Block/Product/View/Options/Type/Select.php
Am I right?

Thanks in advance. smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
dmibau
Member
 
Total Posts:  72
Joined:  2010-07-12
 

duplicate, sorry

 
Magento Community Magento Community
Magento Community
Magento Community
 
dmibau
Member
 
Total Posts:  72
Joined:  2010-07-12
 

Sorry for duplicated posts.

@webcitz

What exactly needs to be changed in this file?
I\’d like to do the same trick as The Design Bank:

This code worked really well but it would be a lot nicer to show what the price would be rather than how this option will affect the base price…
I.e Red = £55, Blue = £56 not Red +£1, Blue + £2

 
Magento Community Magento Community
Magento Community
Magento Community
 
benz001
Sr. Member
 
Avatar
Total Posts:  238
Joined:  2009-02-05
Sydney
 

To address the original thread question (ie the price difference being shown for configurable products), you can easily remove this by overriding the javascript object’s method that updates this string, doing it this way means you only change your template file - no core changes are required.

Look for the template:
catalog/product/view/type/options/configurable.phtml

Around line 44 you’ll find:

var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);

Immediately before it we rewrite the function

//Rewrite the function
    Product.Config.prototype.formatPrice = function(){
        
return '';
    
}
        
var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);
 
Magento Community Magento Community
Magento Community
Magento Community
 
John Y
Jr. Member
 
Avatar
Total Posts:  30
Joined:  2008-12-02
 

@coolshop

thanks! worked perfectly for me. v1.4.2.0

 
Magento Community Magento Community
Magento Community
Magento Community
 
Abhinav Dude
Jr. Member
 
Avatar
Total Posts:  20
Joined:  2010-08-29
Noida, India
 

Hello benz001,
It Work for me on magento 1.5. Thanks.

Cheers smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
tahirmajeed
Jr. Member
 
Total Posts:  1
Joined:  2012-06-17
 

Hi there,
i am using 1.7x this is not working for my case please help me too

 
Magento Community Magento Community
Magento Community
Magento Community
 
redsy
Jr. Member
 
Total Posts:  17
Joined:  2011-06-04
 

I’m also using 1.7 and it’s not working, does anyone have a solution?

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
CyberNetikz
Jr. Member
 
Avatar
Total Posts:  1
Joined:  2010-11-26
New York/ USA, Dhaka/Bangladesh
 

Using jQuery you can easily fix this issue. grin

Complete solutions here:
http://www.cybernetikz.com/blog/remove-price-configurable-products-dropdown-options-magento/

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 2