I am trying to implement flat pricing for Craft (ie. different fixed prices for products, based on the currency). I have it working thanks to this post (Craft Commerce: Hard code different product prices based on currency?), but where I am having problems is with applying sales.
The site I am working on has different prices for different currencies. These are fixed prices that are not based on Craft’s built-in exchange rates for different currencies. For example, a product in Currency A has a price of $100, which is stored in the Commerce’s default price field. However, the price for that product in Currency B has a price of $1000 - and that is stored in a custom text field for that product.
When a person orders a product in Currency B, I intervene on the
LineItems::EVENT_POPULATE_LINE_ITEM event and manually set the price to Currency B’s price (from the custom text field on that product). This works except for when there are sales for that product.
If there is a sale which applies a 10% discount to the product, then Currency A’s price would be $90 (reduced by $10). However, when someone ordering with Currency B buys that product (which is $1000), that price gets reduced by only $10 (instead of $100). So it appears Commerce is calculating the discount based on Currency A’s price of $100 and applying that to whatever is the line item’s price.
I’ve written a method to calculate Currency B’s final sale price based on the discounts applied to Currency A.
However, it seems the sale’s discount is applied again after the populate line item event so even if I use my method to apply and calculate the correct Currency B sale price, Craft still applies the $10 sales discount again.
Is there a way for me to tell Craft not to apply the sale discount and let me do it manually if a product is being ordered in Currency B?