Skip to content

Commit

Permalink
Merge branch 'refs/heads/develop' into BP-3652-Implement-Buckaroo-Hos…
Browse files Browse the repository at this point in the history
…ted-Fields
  • Loading branch information
vegimcarkaxhija committed Aug 9, 2024
2 parents acdc420 + dce5956 commit be42232
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 14 deletions.
40 changes: 29 additions & 11 deletions Model/Push.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
use Buckaroo\Magento2\Model\Method\Voucher;
use Buckaroo\Magento2\Model\Refund\Push as RefundPush;
use Buckaroo\Magento2\Model\Validator\Push as ValidatorPush;
use Magento\Customer\Api\Data\GroupInterface;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Filesystem\DirectoryList;
use Magento\Framework\ObjectManagerInterface;
Expand Down Expand Up @@ -389,9 +388,7 @@ private function updateOrderWithAddresses($shippingAddress, $billingAddress)
$orderAddressRepository->save($orderBillingAddress);
}

$this->updateGuestCustomerInformation($order, $billingAddress);


$this->updateCustomerInformation($order, $billingAddress);

} catch (\Exception $e) {
$this->logging->addDebug(__METHOD__ . '|Failed to update addresses|');
Expand All @@ -408,25 +405,46 @@ private function updateOrderWithAddresses($shippingAddress, $billingAddress)
* @param Order $order
* @param array $billingAddress
*/
private function updateGuestCustomerInformation(Order $order, array $billingAddress)
private function updateCustomerInformation(Order $order, array $billingAddress)
{
if ($this->isGuestOrder($order)) {
$this->updateGuestInformation($order, $billingAddress);
} else {
$this->updateRegisteredCustomerInformation($order);
}

$order->save();
}

private function isGuestOrder(Order $order): bool
{
return !$order->getCustomerId();
}

private function updateGuestInformation(Order $order, array $billingAddress): void
{
if ($order->getCustomerGroupId() == GroupInterface::NOT_LOGGED_IN_ID) {
// For guest customers, use billing address details
try {
$customerEmail = $this->postData['brq_service_ideal_contactdetailsemail'] ?? $order->getCustomerEmail();
$order->setCustomerEmail($customerEmail);
$order->setCustomerFirstname($billingAddress['firstname'] ?? $order->getCustomerFirstname());
$order->setCustomerLastname($billingAddress['lastname'] ?? $order->getCustomerLastname());
}else{
// For registered customers, use their stored details
} catch (\Exception $e) {
$this->logging->addError('Error updating guest information: '. $e->getMessage());
}
}

private function updateRegisteredCustomerInformation(Order $order): void
{
try {
$customer = $order->getCustomer();
if ($customer) {
$order->setCustomerFirstname($customer->getFirstname() ?? $order->getCustomerFirstname());
$order->setCustomerLastname($customer->getLastname() ?? $order->getCustomerLastname());
$order->setCustomerEmail($customer->getEmail() ?? $order->getCustomerEmail());
}
} catch (\Exception $e) {
$this->logging->addError('Error updating registered customer information: '. $e->getMessage());
}

$order->save();
}

private function pushProcess()
Expand Down
2 changes: 1 addition & 1 deletion Service/Software/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Data
const MODULE_CODE = 'Buckaroo_Magento2';

/** Version of Module */
const BUCKAROO_VERSION = '1.49.0';
const BUCKAROO_VERSION = '1.49.1';

/** @var ProductMetadataInterface */
private $productMetadata;
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"docs": "https://docs.buckaroo.io/"
},
"homepage": "https://www.buckaroo.nl",
"version" : "v1.49.0",
"version" : "v1.49.1",
"minimum-stability": "stable",
"autoload": {
"files": [
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Buckaroo_Magento2:etc/buckaroo_module.xsd">
<module name="Buckaroo_Magento2" setup_version="1.49.0" build_number="1769" stability="stable">
<module name="Buckaroo_Magento2" setup_version="1.49.1" build_number="1769" stability="stable">
<sequence>
<module name="Magento_Payment"/>
<module name="Magento_ReleaseNotification"/>
Expand Down

0 comments on commit be42232

Please sign in to comment.