diff --git a/Model/Adminhtml/Source/CustomerGroup.php b/Model/Adminhtml/Source/CustomerGroup.php index 6dc71842346..a72a6e3faf4 100644 --- a/Model/Adminhtml/Source/CustomerGroup.php +++ b/Model/Adminhtml/Source/CustomerGroup.php @@ -24,6 +24,9 @@ public function toOptionArray(): array { $groups = $this->groupManagement->getLoggedInGroups(); + $notLoggedInGroup = $this->groupManagement->getNotLoggedInGroup(); + array_unshift($groups, $notLoggedInGroup); + $output = []; foreach ($groups as $group) { $output[] = [ diff --git a/Service/Mollie/PointOfSaleAvailability.php b/Service/Mollie/PointOfSaleAvailability.php index 07b6b4c6bc4..98520783746 100644 --- a/Service/Mollie/PointOfSaleAvailability.php +++ b/Service/Mollie/PointOfSaleAvailability.php @@ -29,18 +29,9 @@ public function __construct( public function isAvailable(CartInterface $cart): bool { - $customerId = $this->customerSession->getCustomerId(); - if ($customerId === null) { - return false; - } - $storeId = (int)$cart->getStoreId(); - $allowedGroups = explode(',', $this->config->pointofsaleAllowedCustomerGroups($storeId)); - return in_array( - (string)$this->customerSession->getCustomerGroupId(), - $allowedGroups - ); + return $this->isAvailableForCustomerGroupId((int)$this->customerSession->getCustomerGroupId(), $storeId); } public function isAvailableForCustomerGroupId(int $customerGroupId, int $storeId): bool diff --git a/Test/Integration/Service/Mollie/PointOfSaleAvailabilityTest.php b/Test/Integration/Service/Mollie/PointOfSaleAvailabilityTest.php new file mode 100644 index 00000000000..666e068c21e --- /dev/null +++ b/Test/Integration/Service/Mollie/PointOfSaleAvailabilityTest.php @@ -0,0 +1,43 @@ +objectManager->create(Quote::class); + $cart->load('test01', 'reserved_order_id'); + + /** @var \Mollie\Payment\Service\Mollie\PointOfSaleAvailability $instance */ + $instance = $this->objectManager->get(PointOfSaleAvailability::class); + + $this->assertFalse($instance->isAvailable($cart)); + } + + /** + * @magentoConfigFixture default_store payment/mollie_methods_pointofsale/allowed_customer_groups 0 + * @magentoDataFixture Magento/Sales/_files/quote.php + * @return void + */ + public function testAllowsNotLoggedInAccesWhenConfiguredProperly(): void + { + $cart = $this->objectManager->create(Quote::class); + $cart->load('test01', 'reserved_order_id'); + + /** @var \Mollie\Payment\Service\Mollie\PointOfSaleAvailability $instance */ + $instance = $this->objectManager->get(PointOfSaleAvailability::class); + + $this->assertTrue($instance->isAvailable($cart)); + } +}