I'm having an real issue with Custom Options that incorporate the "percent" price-type.
On Simple products, percent-based custom options work as expected, but on Configurable or Bundled, the final price is determined from the base price, and not the base price + additional options (which is what biz requirements dictate):
Config/Bundle Product
base price = $1000
option 1 + $100
option 2 + 5%
_____________________________
= $1150 (instead of $1155);
I haven't been able to find much of anything dealing with this otherwise big problem.
I did find and implement this Answer, but the $finalPrice
returned in Mage_Catalog_Model_Product_Type_Price -> _applyOptionsPrice
is not correctly evaluating the baseprice + upcharge of custom options. Additionally, on the front end, in Products.Options
the solution is not incorporating the base price in the calculation either. I'm assuming the fix is for prior versions of magento (I'm on v1.11).
I suspect the strategy for the fix is correct, but its a highly complex interchange, and I'm not entirely clear what needs to be altered to deal with this issue.
Any thoughts would be most welcome.
Cheers
update
I've had a bit of success on the front end (getting the javascript to update option values and pricing correctly).These changes, however are not getting written in to the price model. When the shopping cart goes to render, for example, the final price is incorporating not the fully loaded price, but a percentage of the parent product:
Here's what I have on the back end (which is not changing any behavior. I'll note that I've just got them copied into the app/local directory atm, but I'll override them properly once I get this logic worked out.
Mage_Catalog_Model_Product_Type_Price
public function getFinalPrice($qty=null, $product)
{
//... aggregate tier and special pricing, then apply custom options
$finalPrice = $product->getData('final_price');
$finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice);
return max(0, $finalPrice);
}
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);
// grab option value based on finalprice
$finalPrice += $group->getOptionPrice($confItemOption->getValue(), $finalPrice);
}
};
}
Mage::log('base price :'.$basePrice.' final price :'.$finalPrice);
return $finalPrice;
}
As far as I can tell, in Mage_Catalog_Model_Product_Type_Configurable_Price, and
Mage_Catalog_Model_Product_Type_Grouped_Price, there is nothing to override, because they each call on the Parent::getFinalPrice
to determine values at each step...
The question remains - how do i modify the pricing models to accommodate a percentage based custom option ??
50 points to someone who can help me work this out. ...
Anyone?