Blogs

Making Payment Method Visible Only For Admin in Magento 2

making-payment-method-visible-only-for-admin-in-magento-2.png

Payment methods such as cash-on-delivery and check/money order need to visible in the admin-panel check-out section and not in the front-end for the customer. Magento 2 provides dynamic functionality to implement this using plugins.

Using one such plugin, we can restrict the payment method to display not on front-end and Admin section. Let us see how!

First you need to create di.xml in your module and add below dependency injections for “Cash On Delivery” and “Check/Moneyorder” payment method.

1.png

Then, here is what you need to do for:

  • Cash-On Delivery

Create Directory Structure for plugins
{Namespace}\Module\Plugin\Payment\Method\CashOnDelivery\;
Create Available.php with below code

2-1.png

  • Check/Moneyorder
Create Directory Structure for plugins
{Namespace}\Module\Plugin\Payment\Method\Checkmo;
Create Available.php with below code
Topics: Magento Magento 2.0

e-Zest Solutions is digital experience engineering company with facilities in the United States (Detroit & San Jose), Germany (Hannover), United Kingdom (London UK) and India (Pune) with global clientele. Our services include custom software development, offshore software development, UX consulting, BigData, Managed cloud Services (Azure & AWS), SharePoint consulting/Migration, Enterprise Java application development, Automated software testing services.