e-Zest members share technology ideas to foster digital transformation.

Making Payment Method Visible Only For Admin in Magento 2

Written by Rajesh Rathod | Oct 11, 2017 10:32:07 AM

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.

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

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