Skip to content

Instantly share code, notes, and snippets.

@magevision
Last active September 15, 2022 14:44
Show Gist options
  • Save magevision/47f7095990b696974f78e244934df29e to your computer and use it in GitHub Desktop.
Save magevision/47f7095990b696974f78e244934df29e to your computer and use it in GitHub Desktop.
MakeAPaymentMethodOnlyVisibleInAdmin
<?php
namespace MageVision\Blog77\Plugin\OfflinePayments\Model;
use Magento\Backend\Model\Auth\Session;
use Magento\OfflinePayments\Model\Checkmo;
use Magento\Quote\Api\Data\CartInterface;
class CheckmoPlugin
{
private Session $backendSession;
/**
* @param Session $backendSession
*/
public function __construct(
Session $backendSession
) {
$this->backendSession = $backendSession;
}
/**
* @param Checkmo $subject
* @param $result
* @param CartInterface|null $quote
* @return false|mixed
*/
public function afterIsAvailable(
Checkmo $subject,
$result,
CartInterface $quote = null
) {
if ($this->backendSession->isLoggedIn()) {
return $result;
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment