custom options price calculation - magento

How does custom options price calculation work for a fixed and percent price?
I want to change percent calculation functionality from base price to total price.
Currently it's calculating price from base price.
How to change this from base price to total price?
For example:
base price = $10
custom option1 = $10
custom option2 = 10%
default Magento calculation:
Total price = Base price + selected custom option1 + selected custom option.
Total price = $10+$10+ 10% of $10(baseprice) = $21.
But we need this Total price after selecting the custom option:
Total price = $10+$10 = $20.
Total price after select custom option2
Total price = $20 + (10% of Total price)
Total price = $20 + (10% of $20).
Total price = $20 + $2 = $22.
I need to calculate the percentage from the total price, not from the base price. Please advise.

This is done in
Mage_Catalog_Model_Product_Type_Price::_applyOptionsPrice
If this applies only to special products, you might want to create an own product type with a customer price handler.

Related

How to apply shopping cart rule for single product?

we want a discount to be applied when user add to cart 10 M size t-shirts, 10 L size t-shirts and 5 XL size t-shirts (same product) - so total quantity is 25. & we want to give discount only for the product whose quality is 25 or greater?
You can try to create "Shopping Cart Price Rule" with condition on "Quantity in Cart". Does it help you?

How do I set up multiple shopping cart price rules for discount bands in Magento?

I need to apply multiple discounts like this:
When the order total is less than £50: No discount
When the order total is more than £50 but less than £100: £5 off
When the order total is more than £100 but less than £250: £10 off
When the order total is more than £250 but less than £500: £25 off
When the order total is more than £500: £50 off
I’ve tried so many different combinations but I cannot seem to get these rules to work. Please can someone give me instructions on how to set this up?
I am not sure if you have seen that post: Shopping Cart Price Rules.
So the basic idea is:
1) That you go have to specify in the tab "Conditions" the Cart Attribute Subtotal to the price that you want.Or greater than, equal or less..
2) On the tab Actions just add "Fixed amount of discount" and you are set.
For your example:
1) "Conditions" the Cart Attribute Subtotal equal or greater than 50
and again Subtotal equals or less than 100
2) On tab actio : Choose "Fixed amount of discount" and on Discount Amount put 10.
Hope it helps.
You have to create four rules as follows
Go to magento admin > Promotions >
1) First rule
If ALL of these conditions are TRUE :
• Subtotal greater than 50
• Subtotal less than 100
Actions tab
Discount Amount * 5
2) Second rule
If ALL of these conditions are TRUE :
• Subtotal greater than 100
• Subtotal less than 250
• Actions tab
Discount Amount * 10
3) Third Rule
If ALL of these conditions are TRUE :
• Subtotal greater than 250
• Subtotal less than 500
Discount Amount * 25
4) Fourth Rule
If ALL of these conditions are TRUE :
• Subtotal greater than 500
Discount Amount * 50
1) Select status active
2) Select proper website
3) Select Customer groups
4) No specific coupon
5) Proper from date and to date
for more reference
http://www.magentocommerce.com/knowledge-base/entry/what-are-shopping-cart-price-rules-and-how-do-i-use-them

How to recalculate tax on new row total in magento?

I’m making a call to $item->calcRowTotal() on a Mage_Sales_Model_Quote_Item object.
This works great to reset the row total and base row total, but it does not affect the row total including tax (row_total_incl_tax) attribute on the item.
I assume I have to manually do this after I have the new row total but I can’t figure out how to properly calculate the tax and populate the row_total_incl_tax attribute on the item.
Any suggestions would be much appreciated.
Get the tax rate and recalculate row_total_incl_tax. Here's how you can get tax rate.
Assuming your order no. is 101.
$sale = Mage::getModel('sales/sale)->load(101)
$taxModel = Mage::getModel('sales/order_tax')
->load($sale->getId(), 'order_id');
$taxRate = $taxModel->getPercent()
I think you know how to calculate the tax amount based on row total value.
Edit:
Get tax based on product:
$product = Mage::getModel('catalog/product')->load($item-getProductId());
$request = Mage::getSingleton('tax/calculation')
->getRateRequest()
->setProductClassId($product->getTaxClassId());
$taxRate = Mage::getSingleton('tax/calculation')
->getRate($request);
So you know the tax rate, row_total_incl_tax is sum of tax * qty + total amount (or you can calculate anyway you want). May be you need to check if item price is included tax or not, you can do this by Mage::getModel('Tax/Config')->priceIncludesTax()

How to get discount applied on cart line item individually?

How can I get the discount applied on cart line item individually?
Is this possible to get total unit price after applying discount?
To discount applied on cart line item you can use
$item->getDiscountAmount();
To calculate the price subtracting the discount amount $item->getDiscountAmount(), use below
$price = $item->getPrice() - $item->getDiscountAmount();
This will give you the total unit price after discount.

VAT calculation when using pricing including taxes

The prices are including VAT Tax. The VAT % applied is based on the delivery address. When the delivery country is changed and the VAT % changes, the the amount incl. tax is changed.
For example:
An amount of 0.79 euro is calculated as tax which corresponds with a delivery adress in the Netherlands. 19% Vat is applicable.
Price ex VAT 4.94/1,19=4,15
VAT Amount = 4,15*0,19=0,79
This is working fine.
When a change the delivery date to the country Belgium, where the VAT is 21%
Then the all the amount including tax is increaded. This should not happen as we choose use prices including tax.
The calculation thats is made by Magento is based on the price excel tax when 19%
Dutch VAT was applicable and then applied 21 Belgian VAT:
Price EX VAT: 4,15 = wroing amount has not been recalculated
Belgian VAT Amount = 4,15*,21= 0.87 = wrong amount
The correct calculatio should be:
Price ex VAT 4.94/1,21= 4,08 = correct price excl 21% tax
VAT Amount = 4,08*0,21= 0,86 = correct 21% VAT Amount
Total price = 4,94 incl. VAT
For Belgium i get this price 5,02 and it should be 4,94.
Desired Outcome:
The amount incl tax should stay the same regardless of the VAT% applied.
How can i fix this.
In fact i don't think your reasoning is good.
i explain:
the base price value of the product is it VAT free value.
For a given country, the product is applied a VAT to comply with country VAT related rates.
For wathever country you deliver the product, what changes is VAT but not product base price value , otherwise you'll loose some margin.
Say:
product A VAT Free price is : 100 and you bought it 80 (20 eur margin)
VAT for Netherlands is 19 : Taxed price for Netherlands => 119
VAT for Belgium is 21 : Taxed price for Belgium => 121
Wanting to keep 119 for Belgium would make loose you 2 euros ,since you would have virtually sold it for 98.
If that's really what you want to do : ie , flat price whatever VAT Rate is applide ,Then a "trick" might be to create customer groups based on their country & used tier pricing to reduce product base price in order to maintain VAT rate independent taxed price. (which i wouldn't recommend)

Resources