I have a custom plugin that follows this guide:
Magento 2 - discount depend on Payment Method does not work

So customer will get 4% discount if they choose online payment solution instead of bank transfer. It worked fine in Magento 2.2.6, but when the shop has upgraded to Magento 2.3.2, the payment method in the cart price condition can not be saved. (the value of choosing payment method is always shown blank at the backend - cart price rule)

Here is the main code:


 * Copyright © 2016 MagestyApps. All rights reserved.
 *  * See COPYING.txt for license details.

namespace MagestyApps\FixRules\Controller\Checkout;

use Magento\Checkout\Model\Cart;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\ResponseInterface;
use Magento\Framework\Controller\Result\ForwardFactory;
use Magento\Framework\Controller\ResultInterface;
use Magento\Framework\View\LayoutFactory;
use Magento\Quote\Model\Quote;

class ApplyPaymentMethod extends Action
     * @var ForwardFactory
    protected $resultForwardFactory;

     * @var LayoutFactory
    protected $layoutFactory;

     * @var Cart
    protected $cart;

     * @param Context $context
     * @param LayoutFactory $layoutFactory
     * @param ForwardFactory $resultForwardFactory
    public function __construct(
        Context $context,
        ForwardFactory $resultForwardFactory,
        LayoutFactory $layoutFactory,
        Cart $cart
    ) {
        $this->resultForwardFactory = $resultForwardFactory;
        $this->layoutFactory = $layoutFactory;
        $this->cart = $cart;


     * @return ResponseInterface|ResultInterface|void
     * @throws \Exception
    public function execute()
        $pMethod = $this->getRequest()->getParam('payment_method');

        /** @var Quote $quote */
        $quote = $this->cart->getQuote();






namespace MagestyApps\FixRules\Plugin;

use Magento\SalesRule\Model\Rule\Condition\Address;

class AddPaymentMethodOptionBack
     * @param Address $subject
     * @param $result
     * @return Address
    public function afterLoadAttributeOptions(Address $subject, $result)
        $attributeOption = $subject->getAttributeOption();
        $attributeOption['payment_method'] = __('Payment Method');


        return $subject;


 * Copyright © 2016 MagestyApps. All rights reserved.
 *  * See COPYING.txt for license details.

    function (quote, fullScreenLoader, jQuery, getTotalsAction, url) {
        'use strict';
        return function (paymentMethod) {

            var linkUrl = url.build('magestyapps_fixrules/checkout/applyPaymentMethod');
            jQuery.ajax(linkUrl, {
                data: {payment_method: paymentMethod},
                complete: function () {


Can anyone help to see why the payment method can't be saved in cart price rule at the back-end (Magento 2.3.2)?

Thanks in advance

1 Answer 1


Please refer the following answer you need to change in one file to get all the payment method when you create the payment rule

All payment methods are not coming in Cart Price Rule

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.