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

Magento 2 - Vue Storefront PWA Integration: How to create a new VSBridge indexer job and Elastic Index for your custom module