Magento Forum

How do I set up Simple Product Options that have fixed price values regardless of quantity? 
 
dalberts69
Jr. Member
 
Avatar
Total Posts:  16
Joined:  2008-12-03
 

I’m trying to set up a scenario where custom options values for a simple product affect the price regardless of quantity. Right now, fixed price options affect the base price, and get multiplied by the number of products ordered. I just want a single option price regardless of quantity.

Example:

A customer orders business cards. If the customer wants a PDF proof it adds $5.00 to the price, a hard copy proof adds $15 to the price, and no proof adds nothing. These option pricing needs to be added regardless of the quantity ordered.

Currently, if a base business card price is $0.03, and the customer orders 1000 and wants a PDF proof for $5.00 the base price changes to $5.03 x 1000 = $5,030.00, which is not what I want. I want ($0.03 x 1000) + $5.00 = $35.00.

I’m looking to find where I can make this happen and stop the fixed price option value from getting added to the base price.

I really can’t hardwire so to speak these values since there will be many different types of products (business cards, flyers, etc) and the hard copy/pdf price may change, as well as other options potentially (coatings, turnaround, etc).

I’m pretty clear on the module system if that helps.

 
Magento Community Magento Community
Magento Community
Magento Community
 
szotyi
Sr. Member
 
Total Posts:  153
Joined:  2008-11-29
 

it took me 2 hours to figure that out :S

so:
index.php
insert at the begining of the page

global $hack;

/app/code/core/Mage/Sales/Model/Quote/Item/Abstract.php
find: public function calcRowTotal()
before $qty = $this->getQty(); insert:

global $hack;

find in the same function:
$this->setRowTotal($this->getStore()->roundPrice($total));
$this->setBaseRowTotal($this->getStore()->roundPrice($baseTotal));
replace to:

$this->setRowTotal($this->getStore()->roundPrice($total+$hack));
$this->setBaseRowTotal($this->getStore()->roundPrice($baseTotal+$hack));

/app/code/core/Mage/Catalog/Model/Product/Type/Price.php
find protected function _applyOptionsPrice($product, $qty, $finalPrice)
before if ($optionIds = $product->getCustomOption(’option_ids’)) { insert :

global $hack;
$hack 0;

within the same function you will find THREE times $finalprice +=
replace to:

$hack +=

It works for me but i do not know did I break something or not.. so test everything!
ps.: I found a little bug:
if you have only one item of a certain product in the cart and you have both UNIT price showed(exl. and incl. taxes) the incl. taxes shows the value with the custom option…

 
Magento Community Magento Community
Magento Community
Magento Community
 
dalberts69
Jr. Member
 
Avatar
Total Posts:  16
Joined:  2008-12-03
 

Thanks a huge amount. Although your fix didn’t quite work out (the fixed value options did work, but the percentage ones (these would be a percentage of the total cost, i.e. (1000 qty x $0.03 = $30) + ($30 x 10% cost option) = $33.00, that were working before broke), but it does give me a huge head start, as I now know how the calculation method works.

If you have any ideas, please let me know, but I think I can use your method and tweak it.

Thanks again!

 
Magento Community Magento Community
Magento Community
Magento Community
 
szotyi
Sr. Member
 
Total Posts:  153
Joined:  2008-11-29
 

so then u just check the type of the option… fixed or precent… in the _applyOptionsPrice function
original:

$finalPrice += $this->_getPricingOptionValue(array(
                                
'is_percent' => ($option->getValueById($value)->getPriceType() == 'percent')? true:false,
                                
'pricing_value' => $option->getValueById($value)->getPrice()
                            ), 
$basePrice);

new:

if ($option->getValueById($optionValue)->getPriceType() == 'percent'{
 $finalPrice 
+= $this->_getPricingOptionValue(array(
                                
'is_percent' => ($option->getValueById($value)->getPriceType() == 'percent')? true:false,
                                
'pricing_value' => $option->getValueById($value)->getPrice()
                            ), 
$basePrice);
else {
 $hack 
+= $this->_getPricingOptionValue(array(
                                
'is_percent' => ($option->getValueById($value)->getPriceType() == 'percent')? true:false,
                                
'pricing_value' => $option->getValueById($value)->getPrice()
                            ), 
$basePrice);
}
etc etc
 
Magento Community Magento Community
Magento Community
Magento Community
 
dalberts69
Jr. Member
 
Avatar
Total Posts:  16
Joined:  2008-12-03
 

I love you.

That worked perfectly!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mosses Akizian
Sr. Member
 
Avatar
Total Posts:  176
Joined:  2009-04-28
Los Angeles, CA
 

@szotyi Thanks. Great hack. Tested it and it works. But my site requires fixed per unit surcharge options also, trying to find a way to add to your hack to solve this dilemma. Any insight would be appreciated.

Here’s my posting with a clip before finding @dalberts69 post. http://www.magentocommerce.com/boards/viewthread/41645/

 
Magento Community Magento Community
Magento Community
Magento Community
 
cevans73
Jr. Member
 
Total Posts:  8
Joined:  2009-01-13
 

I like the hack, but is there a way to add this option as a ‘one-time’ fee instead of changing the fixed option....I need both,....so if we were able to somehow add a ‘one-time fee’ option in the drop down on the back end in ADDITION to ‘fixed’ and ‘percentage’, THEN THAT WOULD BE AWESOME!  I CAN’T BELIEVE NOONE AS DONE THIS YET....SEEMS LIKE AN INVALUABLE FEATURE.

Don’t care too much for the ‘extra fee’ mod, as this does not factor into custom options.

ANYONE THAT CAN DO THIS IS MY HERO!!!! AND SHOULD MAKE A MOD OUT OF IT!

 
Magento Community Magento Community
Magento Community
Magento Community
 
studio7
Jr. Member
 
Avatar
Total Posts:  10
Joined:  2009-05-27
Fargo, ND
 

This sort of looks like what I need, but I seem to be running into issues with the Price.php file.  It appears like some things have been changed in how Magento processes the finalPrice variable.  Is there any updates or changes that need to be made to accommodate the updated code?

 
Magento Community Magento Community
Magento Community
Magento Community
 
jonmck
Sr. Member
 
Total Posts:  234
Joined:  2009-02-02
Birmingham, AL
 

Did you successfully implement this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
jonmck
Sr. Member
 
Total Posts:  234
Joined:  2009-02-02
Birmingham, AL
 

Did you have success?  Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
jonmck
Sr. Member
 
Total Posts:  234
Joined:  2009-02-02
Birmingham, AL
 

Does anyone have a solution to try?

Thanks for any help you can give!

 
Magento Community Magento Community
Magento Community
Magento Community
 
jonmck
Sr. Member
 
Total Posts:  234
Joined:  2009-02-02
Birmingham, AL
 

any luck?  I am still working on this....

thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top