First of all let you go to download an extension Magebuzz_Customoption to automatically select one of the specified options in the drop-down. After installing you’ll see a menu in the admin panel to automatically select one option by default.

Create custom option as much as you need. Let’s assume 4 custom option (Material, Thickness, Width, Ring Size)
Add multiple options to these custom option with its value.
Now here is the calculation I need
Final Price= ?
Material Price
= user
defined value
Final Price=Material Price
Thickness Price = Final Price * Thickness Price Value
Final Price=Thickness Price
Width Price = (Final Price / 8 ) * Width Price Value
Final Price=Width Price
Ring Size Price = Final Price + (% of Ring Size Price Value)
Final Price=Ring Size Price
To show that calculation on pages of cart, etc, let’s go to \app\code\core\Mage\Catalog\Model\Product\Type\Price.php
Edit _applyOptionsPrice method of Mage_Catalog_Model_Product_Type_Price class
protected function _applyOptionsPrice($product, $qty, $finalPrice) {
if ($optionIds = $product->getCustomOption('option_ids')) {
$basePrice = $finalPrice;
foreach (explode(',', $optionIds->getValue()) as $optionId) { if ($option = $product->getOptionById($optionId)) {
$confItemOption = $product->getCustomOption('option_' . $option->getId());
$group = $option->groupFactory($option->getType())
->setOption($option)
->setConfigurationItemOption($confItemOption);
if (in_array($option['default_title'], array('material', 'Material'))) { // MP = MP;
$finalPrice = $finalPrice + $group->getOptionPrice($confItemOption->getValue(), $basePrice);
} elseif (in_array($option['default_title'], array('Thickness', 'thickness'))) { // TP = MP * TV;
$thikness_price = $finalPrice * $group->getOptionPrice($confItemOption->getValue(), $basePrice);
$finalPrice = $thikness_price;
} elseif (in_array($option['default_title'], array('Width', 'width'))) { //WP = TP / 8 * WV;
$width_price = ($finalPrice / 8 ) * $group->getOptionPrice($confItemOption->getValue(), $basePrice);
$finalPrice = $width_price;
} elseif (in_array($option['default_title'], array('Ring Size', 'ring size', 'Ring size', 'ring Size', 'ring_size'))) { //RSP = WP * RS%;
$rsp = $finalPrice + (($finalPrice / 100) * $group->getOptionPrice($confItemOption->getValue()) );
$finalPrice = $rsp;
} else {
$finalPrice += $group->getOptionPrice($confItemOption->getValue(), $basePrice);
}
}
}
}
return $finalPrice;
}
If now you’ll see your product detail page & your cart page, both price will be differ, because, till now you have only configured custom price on cart & onward pages. Now let’s move to customize product detail page custom price
First of all we’ll go to \app\code\local\Magebuzz\Customoption\Block\Catalog\Product\View\Options\Type\Select.php to add a new html attribute to select element.
Add
$extraParams .= ' label="' . $_option->getTitle() . '"';
after
$extraParams .= ' onchange="opConfig.reloadPrice()"';
Now let’s go to assign label of custom option to a variable which’ll be sent ahead for further process.
search for : if (typeof (configOptions[selectOption.value]) != ‘undefined’)
inside the if block add this code
configOptions[selectOption.value].options_label = element.getAttribute("label");
Now let’s go to js file which will change price dynamically according to your choice on the product detail page.
File path: \js\varien\product.js
search for : Object.values(this.customPrices).each(function (pair)
inside that add this :
if (pair.excludeTax && pair.includeTax) {
if (pair.options_label == 'Material') {
//MP : Material Price
subPrice += parseFloat(pair.excludeTax);
subPriceincludeTax += parseFloat(pair.includeTax);
} else if (pair.options_label == 'Thickness') {
//TP : Thinkness price
var thikness_price = subPrice * pair.price;
subPrice = parseFloat(thikness_price);
subPriceincludeTax = parseFloat(thikness_price);
} else if (pair.options_label == 'Width') {
//WP : Width Price
var width_price = (subPrice / 8) * pair.price;
subPrice = parseFloat(width_price);
subPriceincludeTax = parseFloat(width_price);
} else if (pair.options_label == 'Ring Size') {
//RSP : Ring Size Price
var rsp = subPrice + ((subPrice / 100) * pair.price);
//var width_price = (subPrice / 8 ) * pair.price;
subPrice = parseFloat(rsp);
subPriceincludeTax = parseFloat(rsp);
} else {
subPrice += parseFloat(pair.excludeTax);
subPriceincludeTax += parseFloat(pair.includeTax);
}
//subPrice += parseFloat(pair.excludeTax);
//subPriceincludeTax += parseFloat(pair.includeTax);
} else {
if (pair.options_label == 'Material') {
//MP : Material Price
subPrice += parseFloat(pair.excludeTax);
subPriceincludeTax += parseFloat(pair.includeTax);
} else if (pair.options_label == 'Thickness') {
//TP : Thinkness price
var thikness_price = subPrice * pair.price;
subPrice = parseFloat(thikness_price);
subPriceincludeTax = parseFloat(thikness_price);
} else if (pair.options_label == 'Width') {
//WP : Width Price
var width_price = (subPrice / 8) * pair.price;
subPrice = parseFloat(width_price);
subPriceincludeTax = parseFloat(width_price);
} else if (pair.options_label == 'Ring Size') {
//RSP : Ring Size Price
var rsp = subPrice + ((subPrice / 100) * pair.price);
//var width_price = (subPrice / 8 ) * pair.price;
subPrice = parseFloat(rsp);
subPriceincludeTax = parseFloat(rsp);
} else {
subPrice += parseFloat(pair.price);
subPriceincludeTax += parseFloat(pair.price);
}
// subPrice += parseFloat(pair.price);
// subPriceincludeTax += parseFloat(pair.price);
}
Now you’ll be able to see the custom price on product detail page as well