Magento 2: How to add custom discount in cart programmatically?

Refer to how Magento2 applies sales-rule discounts. I applied similar approach to apply custom discount, by creating following files in my module:

Namespace_Module\etc\sales.xml


Namespace_Module\Model\Quote\Discount.php



Namespace_Module\view\frontend\layout\checkout_cart_index.xml



Namespace_Module\view\frontend\layout\checkout_index_index.xml



If Fetch is not showing the custom discount description, it was a core magento bug, see this ticket for patch details: https://github.com/magento/magento2/issues/3594

Comments

Popular posts from this blog

XDebug - PHPStorm - Mac: How to configure Xdebug with PHPStorm on Mac OS and PHP 7.3

Elastic Search - How to install and manage multiple versions of elastic search