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 3
Absolute Pricing for Custom Options (one time charge)
 
cevans73
Jr. Member
 
Total Posts:  8
Joined:  2009-01-13
 

Hey Guys, there is a Wiki that shows how to add an absolute option along with the ‘fixed’ and ‘percentage’ options for custom options.  Here is the link to the wiki..  http://www.magentocommerce.com/wiki/how-to/use-absolute-price-for-custom-options.  The problem with this is step 3, the code is says to find, is not there, so maybe it was for an older version?  I am using 1.3.2.1.  I was hoping someone could verify step 3 code for me and hopefully can specify the code more than what was in the wiki.....please!

Thanks!
Chris

 
Magento Community Magento Community
Magento Community
Magento Community
 
captivedesign
Jr. Member
 
Total Posts:  3
Joined:  2009-07-15
 

Yes, please update this if anyone has any input on how to handle this.  The code from the price.php file has apparently been rewritten since the wiki was written.  This would be an awesome option!

 
Magento Community Magento Community
Magento Community
Magento Community
 
devkitchen
Jr. Member
 
Avatar
Total Posts:  8
Joined:  2009-06-19
Germany, Nuremberg
 

Hi,

i think have a solution (Magento 1.3.2.3) but at the moment it is nor really finished and works only with radio options.
i think i can say: “It’s a alpha version of the alpha version” wink

- app/code/core/Mage/Adminhtml/Model/System/Config/Source/Product/Options/Price.php

return array(
        array(
'value' => 'fixed''label' => Mage::helper('adminhtml')->__('Fixed')),
        array(
'value' => 'percent''label' => Mage::helper('adminhtml')->__('Percent')),
        array(
'value' => 'absolute''label' => Mage::helper('adminhtml')->__('Absolute'))
);

- app/code/core/Mage/Catalog/Model/Product/Option/Type/Price/Select.php LINE ~ 195 (Select == GroupType for radio’s)

$this->_isSingleSelection()
...
$result $this->_getChargableOptionPrice(
        
$option->getValueById($optionValue)->getPrice(),
        
$option->getValueById($optionValue)->getPriceType() == 'percent',
        
$basePrice,
        
$option->getValueById($optionValue)->getPriceType() == 'absolute'
);

- app/code/core/Mage/Catalog/Model/Product/Option/Type/Default.php LINE ~ 343

protected function _getChargableOptionPrice($price$isPercent$basePrice$isAbsolutePrice false)
{
        
if ($isAbsolutePrice{
                
return $price -= $basePrice;
        
}
        
else {
                
if($isPercent{
                        
return ($basePrice $price 100);
                
else {
                        
return $price;
                
}
        }
}

- js/varien/product.js - Line: 585:

if (optionPrices == 0{
       
var price optionPrices+parseFloat(_productPrice)
}
else {
       price 
optionPrices;
}

Warning: with this code the price (product view) displayed always as an absolute value. Has anybody a solution for this problem? (Getting the PriceType in JS?). At the moment i only need absolute option prices, so this is ok for me but do you have mixed price types, that code is suboptimal!

Database:

Table -> *_catalog_product_option_type_priceField -> price_type
Change enum to
enum('fixed''percent''absolute')

Sorry for my english, it is a bit (or better said really?) rusty smile

- Edited on 08/15/09

To prevent the “+” sign in the frontend use the following code:

- app/code/core/Mage/Catalog/Block/Product/View/Options/Type/Select.php LINE ~ 100

$priceStr $this->_formatPrice(array(
        
'is_percent' => ($_value->getPriceType() == 'percent') ? true false,
        
'pricing_value' => $_value->getPrice(true),
        
'is_absolute' => ($_value->getPriceType() == 'absolute') ? true false
));

- app/code/core/Mage/Catalog/Block/Product/View/Options/Abstract.php LINE ~ 112

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

        
/* changed */
        
if ($value['is_absolute']{
                $sign 
'';
        
}
        
else {
                $sign 
'+';
        
}

        
...

regards,

eric

 
Magento Community Magento Community
Magento Community
Magento Community
 
cushionguru
Jr. Member
 
Total Posts:  19
Joined:  2008-08-04
 

Thanks for all your work on this.

I modified each piece of code as instructed, but I could not open the CUSTOM OPTIONS in the product. And I ended up with a blank screen when I tried to add it to the cart.

Any help??

You would think this would be a feature of the cart - every other cart I know has this option......

 
Magento Community Magento Community
Magento Community
Magento Community
 
cushionguru
Jr. Member
 
Total Posts:  19
Joined:  2008-08-04
 

Perhaps I put the js code the wrong place. Could this be the problem?....

if (optionPrices == 0) {
var price = optionPrices+parseFloat(_productPrice)
}
else {
price = optionPrices;
}

Could you be more specific about where this goes in the js......

Danke schön

 
Magento Community Magento Community
Magento Community
Magento Community
 
devkitchen
Jr. Member
 
Avatar
Total Posts:  8
Joined:  2009-06-19
Germany, Nuremberg
 

Hi,

reload: function() {  
        
        
...
        
        if ($(
pair.value)) {
                
if (pair.value == 'old-price-'+this.productId && this.productOldPrice != this.productPrice{
                        _productPrice 
this.productOldPrice;
                        
_plusDisposition this.oldPlusDisposition;
                        
_minusDisposition this.oldMinusDisposition;
                
else {
                        _productPrice 
this.productPrice;
                        
_plusDisposition this.plusDisposition;
                        
_minusDisposition this.minusDisposition;
                
}
                
                
/*  DIRTY */
                
if (optionPrices == 0{
                        
var price optionPrices+parseFloat(_productPrice)
                
}
                
else {
                        price 
optionPrices;
                
}

But i think this is not a JS problem. Can you post a link to you store? (And you have a PM smile)

Edit: By the way, I added two code blocks in my first post, to prevent the “+” sign

Regards,

 
Magento Community Magento Community
Magento Community
Magento Community
 
cushionguru
Jr. Member
 
Total Posts:  19
Joined:  2008-08-04
 

Eric

the store is at http://www.duetinteriors.com. I will put the code changes back up.

Thanks for your help!!

How do I make these changes for a drop down list instead of a radio button??

Kit

 
Magento Community Magento Community
Magento Community
Magento Community
 
cushionguru
Jr. Member
 
Total Posts:  19
Joined:  2008-08-04
 

I have the edited files running. I do not seem to be able to get into CUSTOM OPTIONS in the manage Products. This link no longer works.
Either in ADMIN or in the product. Any headway made on this will be gladly received…

 
Magento Community Magento Community
Magento Community
Magento Community
 
cushionguru
Jr. Member
 
Total Posts:  19
Joined:  2008-08-04
 

Has there been any progress on this modification. I am keen to get it implemented..

 
Magento Community Magento Community
Magento Community
Magento Community
 
devkitchen
Jr. Member
 
Avatar
Total Posts:  8
Joined:  2009-06-19
Germany, Nuremberg
 

Hi,

Sorry for this delay. I’m pretty much stressed out at the moment, i try to answer you in the next few days. Ohh and i cant access http://www.duetinteriors.com/, domain was not found.

regards

 
Magento Community Magento Community
Magento Community
Magento Community
 
cushionguru
Jr. Member
 
Total Posts:  19
Joined:  2008-08-04
 

Eric, Thanks so much for your help here, I really appreciate it. Yes that is the correct address http://www.duetinteriorcollections.com/

I have corrected the urls. I changed it over for the IP to the www url.

We have had a change of plan and will make this a lot simpler. What we would like to do is to ONLY HIDE the +$ on each row. So for example at product http://www.duetinteriorcollections.com/index.php/for-the-table/tablecloths-and-table-runners/venice-hem.html
instead of SIZE line 2 showing 68” x 106” +$25.00
I would like it to show the text without the +$25.00
i.e. 68” x 106”

The price at the bottom of the page will still calculate properly

can you tell me which lines of code i need to change to achieve this.

Image Attachments
Picture 6.png
 
Magento Community Magento Community
Magento Community
Magento Community
 
cushionguru
Jr. Member
 
Total Posts:  19
Joined:  2008-08-04
 

SOLVED HIDING THE +$ price

- app/code/core/Mage/Catalog/Block/Product/View/Options/Abstract.php LINE ~ 136
line 136 to 141 looks like this
}
}
if ($flag) {
$priceStr = ‘<span class="price-notice">’.$priceStr.’</span>’;
}

return $priceStr;
}

CHANGED TO THE FOLLOWING
}
}
}

This will hide and +$ amounts or % amounts after the product option.

 
Magento Community Magento Community
Magento Community
Magento Community
 
pakua
Jr. Member
 
Total Posts:  1
Joined:  2009-01-10
 

I have a hack fix for the Absolute vs. Fixed for the javascript mentioned above.

Edit:  /js/varien/product.js

around line 643 -

var abs_or_fixed document.getElementById('absorfixed').innerHTML;

        if (
abs_or_fixed=="ABS"

                price 
optionPrices;

        
else {
            
                price 
optionPrices+parseFloat(_productPrice);
        
}

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

Around line 90 look for:

if ($_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_RADIO
            
|| $_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_CHECKBOX
            
{

and after put:

foreach ($_option->getValues() as $_value{
                
if ($_value->getPriceType()=="absolute"{
                    $absolute 
true;
                
}
            }

            
if ($absolute==true
                $selectHtml 
'<div id="absorfixed" style="display:none">ABS</div>';
            
else {
                $selectHtml 
'<div id="absorfixed" style="display:none">FIX</div>';            
            
}

It is a little sloppy but it does work.  You can have Fixed AND Absolute options display properly without having to make the whole site Fixed OR Absolute.

Hope this helps someone!

-Sean

InteractOne, Inc.
http://www.interactone.com

 
Magento Community Magento Community
Magento Community
Magento Community
 
cevans73
Jr. Member
 
Total Posts:  8
Joined:  2009-01-13
 

Hey Sean,

Can you be a little more specific on the first part, for the code in product.js......do we replace code?  or are we adding this code after code that is already there?  I can’t find similar code on the line you provided, just need more specifics on what to do with the code you provided....

Thanks!

Chris

 
Magento Community Magento Community
Magento Community
Magento Community
 
globojomo
Jr. Member
 
Total Posts:  1
Joined:  2009-10-01
 
cushionguru - 29 August 2009 04:09 PM

SOLVED HIDING THE +$ price

- app/code/core/Mage/Catalog/Block/Product/View/Options/Abstract.php LINE ~ 136
line 136 to 141 looks like this
}
}
if ($flag) {
$priceStr = ‘<span class="price-notice">’.$priceStr.’</span>’;
}

return $priceStr;
}

CHANGED TO THE FOLLOWING
}
}
}

This will hide and +$ amounts or % amounts after the product option.

Does anyone know how to do this same thing, but for configurable products? On a simple product with custom options, this solution removes the “+ $” price display from the dropdown, but it does not remove it from the dropdown for a configurable product.

 
Magento Community Magento Community
Magento Community
Magento Community
 
kehskas
Member
 
Total Posts:  34
Joined:  2009-09-26
Murmansk
 

i made all changes from this thread but its don’t work, in admin i can’t select “Absolute” type of price - any ideas?

Magento Ver 1.3.2.4

may be some one refresh wiki article?

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