magento2 – Magento 2 : responsible code for coupon apply

Open the vendor/magento/module-sales-rule/Model/Validator.php class, Then check the following method:

public function process(AbstractItem $item)

Now open: vendor/magento/module-sales-rule/Model/RulesApplier.php
and check:

public function applyRules($item, $rules, $skipValidation, $couponCode)


protected function applyRule($item, $rule, $address, $couponCode)


The following location you have all discount type:


Open vendor/magento/module-sales-rule/Model/Rule/Action/Discount/ToFixed.php and check the following method:

public function calculate($rule, $item, $qty)

(Update (2021-07-17))

Try to add following code after $this->applyRule( in vendor/magento/module-sales-rule/Model/RulesApplier.php:: public function applyRules($item, $rules, $skipValidation, $couponCode)

if ($item->getDiscountAmount() <= 0 ) {

Don’t write the core, you can create a patch or overwrite that class. It’s a bad class which means lots of private property and method of that class.