cancel
Showing results for 
Search instead for 
Did you mean: 

Make a Payment Method only visible in admin

SOLVED
   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

Re: Make a Payment Method only visible in admin

Its not recommended. You can also achieve in Magento 2 by editing the core file.

Folder path: /vendor/magento/module-offline-payments/Model

Now see what method you want to hide from front-end and edit that file.

I wanted to hide Check/Money Order from front-end. So i added the below code before public function at line 47

protected $_canUseCheckout = false;

So my file looks like below now. I hope it helps.

 

<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\OfflinePayments\Model;

/**
* Class Checkmo
*
* @method \Magento\Quote\Api\Data\PaymentMethodExtensionInterface getExtensionAttributes()
*
* @api
* @since 100.0.2
*/
class Checkmo extends \Magento\Payment\Model\Method\AbstractMethod
{
const PAYMENT_METHOD_CHECKMO_CODE = 'checkmo';

/**
* Payment method code
*
* @var string
*/
protected $_code = self::PAYMENT_METHOD_CHECKMO_CODE;

/**
* @var string
*/
protected $_formBlockType = \Magento\OfflinePayments\Block\Form\Checkmo::class;

/**
* @var string
*/
protected $_infoBlockType = \Magento\OfflinePayments\Block\Info\Checkmo::class;

/**
* Availability option
*
* @var bool
*/
protected $_isOffline = true;

/**
* @return string
*/
protected $_canUseCheckout = false;
public function getPayableTo()
{
return $this->getConfigData('payable_to');
}

/**
* @return string
*/
public function getMailingAddress()
{
return $this->getConfigData('mailing_address');
}
}