Skip to content

Commit 82c0f7a

Browse files
swinard-metaSean Winard
andauthored
Send Magento shipment ID to Meta during fulfillment (#551)
* Send Magento shipment ID to Meta during fulfillment * reformat --------- Co-authored-by: Sean Winard <[email protected]>
1 parent a94ee02 commit 82c0f7a

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

app/code/Meta/BusinessExtension/Helper/GraphAPIAdapter.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -711,15 +711,17 @@ public function acknowledgeOrders($ordersRootId, array $orderIds)
711711
*
712712
* @param mixed $fbOrderId
713713
* @param array $items
714+
* @param string $magentoShipmentId
714715
* @param array $trackingInfo
715716
* @param array $fulfillmentAddressData
716717
* @return mixed|\Psr\Http\Message\ResponseInterface
717718
* @throws GuzzleException
718719
*/
719-
public function markOrderAsShipped($fbOrderId, $items, $trackingInfo, $fulfillmentAddressData)
720+
public function markOrderAsShipped($fbOrderId, $magentoShipmentId, $items, $trackingInfo, $fulfillmentAddressData)
720721
{
721722
$request = [
722723
'access_token' => $this->accessToken,
724+
'external_shipment_id' => $magentoShipmentId,
723725
'idempotency_key' => $this->getUniqId(),
724726
'items' => json_encode($items),
725727
'tracking_info' => json_encode($trackingInfo),
@@ -731,8 +733,7 @@ public function markOrderAsShipped($fbOrderId, $items, $trackingInfo, $fulfillme
731733
$request['should_use_default_fulfillment_location'] = true;
732734
}
733735
$response = $this->callApi('POST', "{$fbOrderId}/shipments", $request);
734-
$response = json_decode($response->getBody()->__toString(), true);
735-
return $response;
736+
return json_decode($response->getBody()->__toString(), true);
736737
}
737738

738739
/**

app/code/Meta/Sales/Model/Order/Shipper.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ class Shipper
6565
* @param OrderHelper $orderHelper
6666
*/
6767
public function __construct(
68-
SystemConfig $systemConfig,
68+
SystemConfig $systemConfig,
6969
GraphAPIAdapter $graphAPIAdapter,
70-
ShippingHelper $shippingHelper,
71-
OrderHelper $orderHelper
70+
ShippingHelper $shippingHelper,
71+
OrderHelper $orderHelper
7272
) {
7373
$this->systemConfig = $systemConfig;
7474
$this->graphAPIAdapter = $graphAPIAdapter;
@@ -199,6 +199,7 @@ public function markAsShipped(Shipment $shipment)
199199
$this->markOrderAsShipped(
200200
(int)$storeId,
201201
$fbOrderId,
202+
$shipment->getIncrementId(),
202203
$itemsToShip,
203204
$trackingInfo,
204205
$fulfillmentAddress
@@ -215,24 +216,27 @@ public function markAsShipped(Shipment $shipment)
215216
*
216217
* @param int $storeId
217218
* @param string $fbOrderId
219+
* @param string $magentoShipmentId
218220
* @param array $items
219221
* @param array $trackingInfo
220222
* @param array $fulfillmentAddressData
221223
* @throws GuzzleException
222224
*/
223225
private function markOrderAsShipped(
224-
int $storeId,
226+
int $storeId,
225227
string $fbOrderId,
226-
array $items,
227-
array $trackingInfo,
228-
array $fulfillmentAddressData = []
228+
string $magentoShipmentId,
229+
array $items,
230+
array $trackingInfo,
231+
array $fulfillmentAddressData = []
229232
) {
230233
$this->graphAPIAdapter
231234
->setDebugMode($this->systemConfig->isDebugMode($storeId))
232235
->setAccessToken($this->systemConfig->getAccessToken($storeId));
233236

234237
$this->graphAPIAdapter->markOrderAsShipped(
235238
$fbOrderId,
239+
$magentoShipmentId,
236240
$items,
237241
$trackingInfo,
238242
$fulfillmentAddressData

0 commit comments

Comments
 (0)