|
Apache/2.4.41 (Ubuntu) Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) server ip : 62.171.164.128 | your ip : 127.0.0.1 safemode OFF > / home / dev2.destoffenstraat.com / app / code / Acx / StorePickup / Model / |
Filename | /home/dev2.destoffenstraat.com/app/code/Acx/StorePickup/Model/Payment.php |
Size | 2.48 kb |
Permission | rwxrwxrwx |
Owner | root : root |
Create time | 17-Aug-2025 10:26 |
Last modified | 06-Apr-2021 18:06 |
Last accessed | 21-Aug-2025 22:38 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
<?php
namespace Acx\StorePickup\Model;
use Magento\Config\Model\Config\Source\Locale\Currency\All;
class Payment extends \Magento\Payment\Model\Method\AbstractMethod
{
const PAYMENT_METHOD_IN_STORE_PICKUP_MULTI_CODE = 'storePickupCash';
protected $_code = self::PAYMENT_METHOD_IN_STORE_PICKUP_MULTI_CODE;
/**
* Availability option
*
* @var bool
*/
protected $_isOffline = true;
/**
* @var \Magento\Checkout\Model\Session
*/
private $checkoutSession;
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
\Magento\Framework\Api\AttributeValueFactory $customAttributeFactory,
\Magento\Payment\Helper\Data $paymentData,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Payment\Model\Method\Logger $logger,
\Magento\Checkout\Model\Session $checkoutSession,
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = []
) {
$this->checkoutSession = $checkoutSession;
parent::__construct(
$context,
$registry,
$extensionFactory,
$customAttributeFactory,
$paymentData,
$scopeConfig,
$logger,
$resource,
$resourceCollection,
$data
);
}
private function startsWith($haystack, $needle) {
return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== false;
}
public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote=null)
{
if (is_null($quote) || !$this->getConfigData('active')) {
return false;
}
$shippingMethod = $this->checkoutSession->getQuote()->getShippingAddress()->getShippingMethod();
if (!$this->getConfigData('display_in_frontend')) {
return false;
}
if ($this->startsWith($shippingMethod, Carrier::CODE)
|| $this->getConfigData('ignore_shipping_method')) {
return true;
}
return false;
}
public function getInstructions()
{
return trim($this->getConfigData('instructions'));
}
}
namespace Acx\StorePickup\Model;
use Magento\Config\Model\Config\Source\Locale\Currency\All;
class Payment extends \Magento\Payment\Model\Method\AbstractMethod
{
const PAYMENT_METHOD_IN_STORE_PICKUP_MULTI_CODE = 'storePickupCash';
protected $_code = self::PAYMENT_METHOD_IN_STORE_PICKUP_MULTI_CODE;
/**
* Availability option
*
* @var bool
*/
protected $_isOffline = true;
/**
* @var \Magento\Checkout\Model\Session
*/
private $checkoutSession;
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
\Magento\Framework\Api\AttributeValueFactory $customAttributeFactory,
\Magento\Payment\Helper\Data $paymentData,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Payment\Model\Method\Logger $logger,
\Magento\Checkout\Model\Session $checkoutSession,
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = []
) {
$this->checkoutSession = $checkoutSession;
parent::__construct(
$context,
$registry,
$extensionFactory,
$customAttributeFactory,
$paymentData,
$scopeConfig,
$logger,
$resource,
$resourceCollection,
$data
);
}
private function startsWith($haystack, $needle) {
return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== false;
}
public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote=null)
{
if (is_null($quote) || !$this->getConfigData('active')) {
return false;
}
$shippingMethod = $this->checkoutSession->getQuote()->getShippingAddress()->getShippingMethod();
if (!$this->getConfigData('display_in_frontend')) {
return false;
}
if ($this->startsWith($shippingMethod, Carrier::CODE)
|| $this->getConfigData('ignore_shipping_method')) {
return true;
}
return false;
}
public function getInstructions()
{
return trim($this->getConfigData('instructions'));
}
}