How to use absolute pricing for custom options

Last modified by cevans73 on Fri, June 25, 2010 09:54
Source|Old Revisions  

This is an old revision of the document!


Introduction

When giving a custom option a price, Magento adds that price to the product’s base-price. This entry will show you how to add an extra price type, that allows custom options to override the base price. So instead of having “+ 10 percent” or “+£10 fixed”, you would be able to have “£25 absolute”.

Step 1

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

Replace:

  1. array('value' => 'percent', 'label' => Mage::helper('adminhtml')->__('Percent'))

With:

  1. array('value' => 'percent', 'label' => Mage::helper('adminhtml')->__('Percent')),
  2. array('value' => 'absolute', 'label' => Mage::helper('adminhtml')->__('Absolute'))

Step 2

Edit app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Options.php

Replace:

  1. } elseif ($type == 'fixed') {

With:

  1. } elseif ($type == 'fixed' || $type == 'absolute') {

Step 3

Edit app/code/core/Mage/Catalog/Model/Product/Type/Price.php.

Replace all occurrences of:

  1. $finalPrice += $this->_getPricingOptionValue(array(

With:

  1. $finalPrice = ($option->getValueById($optionValue)->getPriceType() != 'absolute' ? $finalPrice : 0) + $this->_getPricingOptionValue(array(

Notes

You may need to also edit your frontend design accordingly to signify these changes.

Problem: I can’t locate that exact line of code in step 3, are you sure that is the correct code to look for? The closest I find is $finalPrice += $group→getOptionPrice($quoteItemOption→getValue(), $basePrice);

Please be more exact on step 3 code replacement. Thanks!

Yeah, Please be more specific of the last step...this would be an awesome feature to have. Thanks,

Captive Design

I tried to work around it with the fixed price values hack posted here however, it appears like the price.php file has changed in how it handles calculating option prices as of version 1.3.2.1 (feel free to correct version as needed- its the first time I noticed it in my files though).

studio7

-

This would be the best and most useful Wiki EVER, if it actually worked....step 3 code does not exist. Hopefully someday, someone can figure this out, as it is an ABSOLUTE NECESSITY FOR ANY WEBSITE. CAN’T BELIEVE IT’S NOT ALREADY PART OF MAGENTO....ALL THE OTHER CARTS HAVE A ‘ONE TIME FEE’ OPTION...ZENCART...ETC.... WHAT’S UP MAGENTO?? CHRIS




 

Magento 2 GitHub Repository

Magento Job Board - Some sort of tag line goes here

Latest Posts| View all Jobs