Skip to content

Commit 474fe7c

Browse files
Merge pull request #1007 from buckaroo-it/BP-3686-Fix-iDEAL-fast-checkout-issue-with-customer-group
Bp 3686 fix i deal fast checkout issue with customer group
2 parents 902078c + 5e0ac3d commit 474fe7c

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

Model/Push.php

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
use Buckaroo\Magento2\Model\Method\Voucher;
4545
use Buckaroo\Magento2\Model\Refund\Push as RefundPush;
4646
use Buckaroo\Magento2\Model\Validator\Push as ValidatorPush;
47-
use Magento\Customer\Api\Data\GroupInterface;
4847
use Magento\Framework\App\ResourceConnection;
4948
use Magento\Framework\Filesystem\DirectoryList;
5049
use Magento\Framework\ObjectManagerInterface;
@@ -389,9 +388,7 @@ private function updateOrderWithAddresses($shippingAddress, $billingAddress)
389388
$orderAddressRepository->save($orderBillingAddress);
390389
}
391390

392-
$this->updateGuestCustomerInformation($order, $billingAddress);
393-
394-
391+
$this->updateCustomerInformation($order, $billingAddress);
395392

396393
} catch (\Exception $e) {
397394
$this->logging->addDebug(__METHOD__ . '|Failed to update addresses|');
@@ -408,25 +405,46 @@ private function updateOrderWithAddresses($shippingAddress, $billingAddress)
408405
* @param Order $order
409406
* @param array $billingAddress
410407
*/
411-
private function updateGuestCustomerInformation(Order $order, array $billingAddress)
408+
private function updateCustomerInformation(Order $order, array $billingAddress)
409+
{
410+
if ($this->isGuestOrder($order)) {
411+
$this->updateGuestInformation($order, $billingAddress);
412+
} else {
413+
$this->updateRegisteredCustomerInformation($order);
414+
}
415+
416+
$order->save();
417+
}
418+
419+
private function isGuestOrder(Order $order): bool
420+
{
421+
return !$order->getCustomerId();
422+
}
423+
424+
private function updateGuestInformation(Order $order, array $billingAddress): void
412425
{
413-
if ($order->getCustomerGroupId() == GroupInterface::NOT_LOGGED_IN_ID) {
414-
// For guest customers, use billing address details
426+
try {
415427
$customerEmail = $this->postData['brq_service_ideal_contactdetailsemail'] ?? $order->getCustomerEmail();
416428
$order->setCustomerEmail($customerEmail);
417429
$order->setCustomerFirstname($billingAddress['firstname'] ?? $order->getCustomerFirstname());
418430
$order->setCustomerLastname($billingAddress['lastname'] ?? $order->getCustomerLastname());
419-
}else{
420-
// For registered customers, use their stored details
431+
} catch (\Exception $e) {
432+
$this->logging->addError('Error updating guest information: '. $e->getMessage());
433+
}
434+
}
435+
436+
private function updateRegisteredCustomerInformation(Order $order): void
437+
{
438+
try {
421439
$customer = $order->getCustomer();
422440
if ($customer) {
423441
$order->setCustomerFirstname($customer->getFirstname() ?? $order->getCustomerFirstname());
424442
$order->setCustomerLastname($customer->getLastname() ?? $order->getCustomerLastname());
425443
$order->setCustomerEmail($customer->getEmail() ?? $order->getCustomerEmail());
426444
}
445+
} catch (\Exception $e) {
446+
$this->logging->addError('Error updating registered customer information: '. $e->getMessage());
427447
}
428-
429-
$order->save();
430448
}
431449

432450
private function pushProcess()

0 commit comments

Comments
 (0)