Last active
September 15, 2022 14:44
-
-
Save magevision/47f7095990b696974f78e244934df29e to your computer and use it in GitHub Desktop.
MakeAPaymentMethodOnlyVisibleInAdmin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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