Skip to content

Commit

Permalink
20.54.1 SHQ23-474 Update code around order comments to be 2.4 compliant
Browse files Browse the repository at this point in the history
  • Loading branch information
wsajosh committed Apr 10, 2024
1 parent 72db3d7 commit 75dc4dd
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG-PUBLIC.md
Original file line number Diff line number Diff line change
Expand Up @@ -772,3 +772,7 @@ SHQ23-1021 Fix issue with place order call not populating site details
SHQ23-2090 Improve functionality of email template variables


## 20.54.1 (2024-04-10)
SHQ23-474 Update code around order comments to be 2.4 compliant


4 changes: 4 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -772,3 +772,7 @@ SHQ23-1021 Fix issue with place order call not populating site details
SHQ23-2090 Improve functionality of email template variables


## 20.54.1 (2024-04-10)
SHQ23-474 Update code around order comments to be 2.4 compliant


2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "shipperhq/module-shipper",
"description": "Magento Shipping integration with ShipperHQ",
"type": "magento2-module",
"version": "20.54.0",
"version": "20.54.1",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
28 changes: 15 additions & 13 deletions src/Helper/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ public function loadOrderPackagesByOrderId($orderId)
return $orderPackageCollection;
}

/**
* @param \Magento\Sales\Model\Order $order
* @param $shippingAddress
*
* @return void
*/
public function saveOrderPackages($order, $shippingAddress)
{
$orderId = $order->getId();
Expand Down Expand Up @@ -207,30 +213,26 @@ public function saveOrderPackages($order, $shippingAddress)
$boxText = __('Transaction ID: ') . $carrier_group['transaction'];
}

/*
* SHQ18-1700 Thanks to @dewayneholden on Github for this suggested code change
* Using method addStatusHistoryComment() for Magento 2.1 compatibility
* Once 2.1 is EOL we will switch to using addCommentToStatusHistory()
*/
$this->orderStatusHistoryRepository->save($order->addStatusHistoryComment($boxText, $order->getStatus()));

// SHQ18-1700 Thanks to @dewayneholden on Github for this suggested code change
$this->orderStatusHistoryRepository->save($order->addCommentToStatusHistory($boxText));

if (strpos($order->getShippingMethod(), 'multicarrier') === 0) {
$this->orderStatusHistoryRepository->save($order->addStatusHistoryComment(
"Shipping method for " . $carrier_group['name'] . ": " . $carrier_group['carrierTitle'] . " - " . $carrier_group['methodTitle'],
$order->getStatus()
$this->orderStatusHistoryRepository->save($order->addCommentToStatusHistory(
"Shipping method for " . $carrier_group['name'] . ": "
. $carrier_group['carrierTitle'] . " - " . $carrier_group['methodTitle']
));
}

if ($carrier_group['carrierType'] == 'customerAccount') {
$this->orderStatusHistoryRepository->save($order->addStatusHistoryComment(
$this->shipperDataHelper->getCustomerCarrierBreakdownText($carrier_group),
$order->getStatus()
$this->orderStatusHistoryRepository->save($order->addCommentToStatusHistory(
$this->shipperDataHelper->getCustomerCarrierBreakdownText($carrier_group)
));
}
}
}
} catch (\Exception $e) {
//Log exception and move on.
// Log exception and move on.
$this->_logger->critical('ShipperHQ save order package error: ' . $e->getMessage());
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/Observer/AbstractRecordOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ public function __construct(
$this->authHelper = $authHelper;
}

/**
* @param \Magento\Sales\Model\ResourceModel\Order $order
*
* @return void
* @throws \Magento\Framework\Exception\CouldNotSaveException
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function recordOrder($order)
{
// https://github.com/magento/magento2/issues/4233
Expand Down
2 changes: 1 addition & 1 deletion src/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "shipperhq/module-shipper",
"description": "Magento Shipping integration with ShipperHQ",
"type": "magento2-module",
"version": "20.54.0",
"version": "20.54.1",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
2 changes: 1 addition & 1 deletion src/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<ws_timeout>30</ws_timeout>
<use_cache>0</use_cache>
<always_use_cache>1</always_use_cache>
<extension_version>20.54.0</extension_version>
<extension_version>20.54.1</extension_version>
<allowed_methods></allowed_methods>
<magento_version></magento_version>
<cache_timeout>300</cache_timeout>
Expand Down

0 comments on commit 75dc4dd

Please sign in to comment.