Cart rule Discount on payment methods in Magento 2

 

how to give discount on payment methods?


solve criteria 

01 Option "Payment Method" is not showing up in Conditions Tab. I want to give some discount on specific payment methods.
02 how to add Payment Method in to cart Attribute 


after added result will show like this 

Payment Method add to cart Attribute


we will see how to add this

01 open file path

we should open address.php it may have in your below file path check which directory have it 

Magento\SalesRule\Model\Rule\Condition\Address.php  

or 

/var/www/magento/vendor/magento/module-sales-rule/ 

check some file path then you can see file


02 open address.php 


and add this 



copy and paste this text 
 
'payment_method' => __('Payment Method'),






03 open etc\di.xml file 


app\code\magento\SalesRule\etc\di.xml  or 
it will /var/www/magento/vendor/magento/module-sales-rule/etc




paste this code here 
option 01






paste this code bellow or top 

<preference for="Magento\Rule\Model\Condition\AbstractCondition" 
type="Magento\SalesRule\Model\Rule\Condition\Address" />


if not 
some PC/server may have it like this way 
option 02

app\code\magento\SalesRule\etc\di.xml

 <?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">

     <preference for="Magento\SalesRule\Model\Rule\Condition\Address" type="Magento\SalesRule\Model\Rule\Condition\Address" />

</config>


04 open again address.php

check this class name 
option 01



some time it may show bellow way check any one match with you
option 02



* see this this path MUST be same with your di.xml preference path





see above tow image path same 


this is other pc way (this path should be same)
option 02





that's all now you can run update


php bin/magento setup:upgrade
next 
php bin/magento setup:static-content:deploy -f
next 
php bin/magento setup:di:compile
next
sudo chmod -R 777 var pub

finished thank you 


if not success open follow bellow  






04 open module.xml 




it may like this no need change anything 
if not work or success tell me we will send update within 1hr





no need change this keep it default way your pc/server 



these tow name should be same concern about it 
that's all 

next 

when go magneto cart rune now should show 


see the video tutorial  fixing this 





Post a Comment

0 Comments