diff --git a/Model/Config.php b/Model/Config.php index e644bd1..48c6e8e 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -13,6 +13,7 @@ class Config private const IS_ENABLED = 'hyva_themes_checkout/new_customer/enable'; private const SEND_RESET_PASSWORD_MAIL = 'hyva_themes_checkout/new_customer/send_reset_password_mail'; private const NEW_PASSWORD_TEMPLATE = 'hyva_themes_checkout/new_customer/create_password_template'; + private const DEFAULT_CUSTOMER_GROUP_XML_PATH = 'customer/create_account/default_group'; public function __construct(private ScopeConfigInterface $scopeConfig) { @@ -41,4 +42,13 @@ public function getNewPasswordTemplate(): string ScopeInterface::SCOPE_STORE ); } + + public function getDefaultCustomerGroup(?int $storeId = null): int + { + return (int)$this->scopeConfig->getValue( + self::DEFAULT_CUSTOMER_GROUP_XML_PATH, + ScopeInterface::SCOPE_STORE, + $storeId + ); + } } diff --git a/Observer/ConvertGuestToCustomer.php b/Observer/ConvertGuestToCustomer.php index 11376b0..60ec7a9 100644 --- a/Observer/ConvertGuestToCustomer.php +++ b/Observer/ConvertGuestToCustomer.php @@ -56,7 +56,7 @@ public function execute(Observer $observer): void $quote->setCustomerId($customer->getId()) ->setCustomerIsGuest(0) // Ideally we should make this configurable. - ->setCustomerGroupId(\Magento\Customer\Api\Data\GroupInterface::NOT_LOGGED_IN_ID); + ->setCustomerGroupId($this->newAccountConfig->getDefaultCustomerGroup((int)$quote->getStoreId())); /** @var \Magento\Sales\Model\Order $order */ $order = $observer->getEvent()->getOrder();