4
votes

I want the Custom Options in Magento to calculate percentage cost from the already changed price (of other custom options) and not the base price.

I can get the desired results here of calculating percentage based on the changed price value rather than the base price by changing this line of code in app/code/core/Mage/Catalog/Model/Product/Type/Price.php to $finalPrice instead of $basePrice

from this:

$finalPrice += $group->getOptionPrice($quoteItemOption->getValue(), $basePrice);

to this:

$finalPrice += $group->getOptionPrice($quoteItemOption->getValue(), $finalPrice);

However - this successfully updates in the cart price, but does not update the on the fly option price on the product page itself.

Any clue on how to change the price on the product page???

1
I tried to do the same thing on a project but due to time constraints I didn't manage to find all of the "loose ends" where calculation in JavaScript takes place, so I ended up postponing this feature.Mihai Stancu

1 Answers

2
votes

The on the fly option price is built by a JavaScript function defined in a file called configurable.js.

There is a function which (re)builds the html <select> and <option> values every time a value is selected.

There is another function which generates the array of prices / option values and which calls the (re)build function.

TL;DR: There's calculation logic inside the JavaScripts, namely configurable.js.