I have Product relation like below.
Product A - Catalog Search
Product Test1 - Not visible Individually
Product Test2 - Not visible Individually
Once Product A is added to cart,
I am taking the sum of (Test1 + Test1) price and setting the custom price for Product A.
The setting custom price is working fine. This is the code used to set custom price in my controller
$_product = //Product Object created by id $productItem = $this->getProductQuote($_product); $productItem->setCustomPrice($customPrice); $productItem->setOriginalCustomPrice($customPrice); //Enable super mode on the product. $productItem->getProduct()->setIsSuperMode(true); $this->cart->save();
My issue is, I need to apply tax amount for the product programmatically.
I have created two tax Group.
SAMPLE1 Rate 10%
SAMPLE2 Rate 20%
Product Test1 Tax Class is => SAMPLE1
Product Test2 Tax Class is => SAMPLE2
So when Product A added to the cart, I need to get the tax rate for each product based on the product tax class and set custom tax like i set the custom price before.
Can anyone help me how to achieve this functionality please.