Skip to content

Commit

Permalink
Implement setting timezone when updating order state
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandarBoljanovic committed Nov 21, 2023
1 parent 56382fc commit 01f65cc
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/classes/Services/Integration/OrderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use AdyenPayment\Classes\Services\RefundHandler;
use AdyenPayment\Classes\Version\Contract\VersionHandler;
use Cart;
use Configuration;
use DateTime;
use Db;
use Order;
Expand All @@ -21,6 +22,7 @@
use PrestaShop\PrestaShop\Adapter\Entity\Currency;
use PrestaShopDatabaseException;
use PrestaShopException;
use Shop;

/**
* Class OrderService.
Expand Down Expand Up @@ -101,8 +103,8 @@ public function updateOrderStatus(Webhook $webhook, string $statusId): void
if (!$idOrder) {
throw new Exception('Order for cart id: ' . $webhook->getMerchantReference() . ' could not be found.');
}

$order = new Order($idOrder);
$this->setTimezone($order->id_shop);

if ((int)$statusId && (int)$statusId !== (int)$order->current_state) {
$history = new OrderHistory();
Expand Down Expand Up @@ -184,4 +186,23 @@ private function getOrderCurrentState(int $orderId)
"
);
}

/**
* @param int $storeId
*
* @return void
*/
private function setTimezone(int $storeId): void {
$shop = new Shop($storeId);

@date_default_timezone_set(
Configuration::get(
'PS_TIMEZONE',
null,
$shop->id_shop_group,
$shop->id,
Configuration::get('PS_TIMEZONE')
)
);
}
}

0 comments on commit 01f65cc

Please sign in to comment.