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!




 

Magento 2 GitHub Repository

Magento Job Board - Some sort of tag line goes here

Latest Posts| View all Jobs