I'm trying to add custom discount amount on quote to specific product line,
I saw event sales_quote_address_discount_item, when I use it like that :
$item = $observer->getData('item');
$item->setDiscountAmount(10);
$item->setBaseDiscountAmount(10);
$item->save();
In database (quote_item) I can see that column 'discount_amount' and 'base_discount_amount' contains my amount, but nothing on quote table and on quote_address.
How can I apply from code a custom discount on one specific product in quote ?
Best Answer
We are saving custom discount on line item level i.e in quote_item table
Please follow the below steps:
Create sales.xml file in your custom module inside etc directory
create discount.php in [VendorName]/[Namespace]/Model/Quote/Address/Total
Note : This is not the complete code but it will help you to save the custom discount on item level.