10

In Magento 2.3.1 I'm creating Cart Price Rule for Payment Methods. I have to create for Bank Transfer but there is Bank Transfer option not coming.

https://www.screencast.com/t/h4rc4PnQU

2 Answers 2

12
+200

open file vendor/magento/module-payment/Helper/data.php

at line number 268 put this line

$data['active'] = 1;

if you dont want to change in the core file than you need to override that file follow the below code

Go to Vendor/Extension/etc/di.xml And Write below code into 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\Payment\Helper\Data" type="Vendor\Extension\Helper\Data"/>
</config>

Next Step is to Create Data.php file at Vendor\Extension\Helper\Data.php

<?php
namespace Vendor\Extension\Helper;

use Magento\Payment\Helper\Data as MainHelper;

class Data extends MainHelper
{
    public function getPaymentMethodList($sorted = true, $asLabelValue = false, $withGroups = false, $store = null)
    {
        $methods = [];
        $groups = [];
        $groupRelations = [];


        foreach ($this->getPaymentMethods() as $code => $data) {

            $data['active'] = 1;

            if (!empty($data['active'])) {
                $storedTitle = $this->getMethodInstance($code)->getConfigData('title', $store);
                if (isset($storedTitle)) {
                    $methods[$code] = $storedTitle;
                } elseif (isset($data['title'])) {
                    $methods[$code] = $data['title'];
                }
            }
            if ($asLabelValue && $withGroups && isset($data['group'])) {
                $groupRelations[$code] = $data['group'];
            }
        }
        if ($asLabelValue && $withGroups) {
            $groups = $this->_paymentConfig->getGroups();
            foreach ($groups as $code => $title) {
                $methods[$code] = $title;
            }
        }
        if ($sorted) {
            asort($methods);
        }
        if ($asLabelValue) {
            $labelValues = [];
            foreach ($methods as $code => $title) {
                $labelValues[$code] = [];
            }
            foreach ($methods as $code => $title) {
                if (isset($groups[$code])) {
                    $labelValues[$code]['label'] = $title;
                    if (!isset($labelValues[$code]['value'])) {
                        $labelValues[$code]['value'] = null;
                    }
                } elseif (isset($groupRelations[$code])) {
                    unset($labelValues[$code]);
                    $labelValues[$groupRelations[$code]]['value'][$code] = ['value' => $code, 'label' => $title];
                } else {
                    $labelValues[$code] = ['value' => $code, 'label' => $title];
                }
            }

            return $labelValues;
        }


        return $methods;
    }
}
11
  • Not working and i can't edit core files.
    – Magecode
    Commented Jun 18, 2019 at 10:27
  • In Magento 2.3.1 we can create rule using Payment method, but why all the payment methods are not coming there in condition selection?
    – Magecode
    Commented Jun 18, 2019 at 10:27
  • its working for me can you share the screenshot what you place exact, if you dont want to edit core file than you override that file and change Commented Jun 18, 2019 at 10:51
  • meetanshi.d.pr/ynAITh Commented Jun 18, 2019 at 11:08
  • screencast.com/t/0ydCNELqiLs
    – Magecode
    Commented Jun 18, 2019 at 11:09
5

You can use below link

https://magento.stackexchange.com/a/128606/70565

I hope it's usefully for you.

5
  • In Magento 2.3.1 we can create rule using Payment method, but why all the payment methods are not coming there in condition selection?
    – Magecode
    Commented Jun 18, 2019 at 10:19
  • I have check in magento 231 version, in that payment method condition is not available. Commented Jun 18, 2019 at 10:35
  • Are you using any extension or default magento functionality? Commented Jun 18, 2019 at 10:38
  • Default Magento functionality
    – Magecode
    Commented Jun 18, 2019 at 10:40
  • I have check in default magento 231 version, in that payment method condition is not available. Commented Jun 18, 2019 at 10:42

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.