Skip to content

Commit 8e24c22

Browse files
authored
Rename page id to orders root (#479)
* Renamed page ID variable to orders root ID * Renamed page ID variable to orders root ID
1 parent 3d4df5c commit 8e24c22

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -566,13 +566,13 @@ public function graphAPIBatchRequest(array $requests)
566566
/**
567567
* Get orders
568568
*
569-
* @param mixed $pageId
569+
* @param mixed $ordersRootId Commerce Account ID or Page ID
570570
* @param false|string $cursorAfter
571571
* @param string $filterType
572572
* @return array
573573
* @throws GuzzleException
574574
*/
575-
public function getOrders($pageId, $cursorAfter = false, $filterType = "")
575+
public function getOrders($ordersRootId, $cursorAfter = false, $filterType = "")
576576
{
577577
$requestFields = [
578578
'id',
@@ -609,7 +609,7 @@ public function getOrders($pageId, $cursorAfter = false, $filterType = "")
609609
if ($cursorAfter) {
610610
$request['after'] = $cursorAfter;
611611
}
612-
$response = $this->callApi('GET', "{$pageId}/commerce_orders", $request);
612+
$response = $this->callApi('GET', "{$ordersRootId}/commerce_orders", $request);
613613
return json_decode($response->getBody()->__toString(), true);
614614
}
615615

@@ -683,20 +683,20 @@ public function getOrderItems($fbOrderId)
683683
/**
684684
* Acknowledge orders
685685
*
686-
* @param mixed $pageId
686+
* @param mixed $ordersRootId Commerce Account ID or Page ID
687687
* @param array $orderIds
688688
* @return mixed
689689
* @throws GuzzleException
690690
*/
691-
public function acknowledgeOrders($pageId, array $orderIds)
691+
public function acknowledgeOrders($ordersRootId, array $orderIds)
692692
{
693693
$request = [];
694694
foreach ($orderIds as $magentoOrderId => $fbOrderId) {
695695
$request[] = ['id' => $fbOrderId, 'merchant_order_reference' => $magentoOrderId];
696696
}
697697
$response = $this->callApi(
698698
'POST',
699-
"{$pageId}/acknowledge_orders",
699+
"{$ordersRootId}/acknowledge_orders",
700700
[
701701
'access_token' => $this->accessToken,
702702
'idempotency_key' => $this->getUniqId(),

app/code/Meta/Sales/Helper/CommerceHelper.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ public function __construct(
115115
*/
116116
public function pullOrders(int $storeId, $cursorAfter = false)
117117
{
118-
$ordersRootId = $this->systemConfig->getCommerceAccountId($storeId) ?: $this->systemConfig->getPageId($storeId);
119118
$this->graphAPIAdapter
120119
->setDebugMode($this->systemConfig->isDebugMode($storeId))
121120
->setAccessToken($this->systemConfig->getAccessToken($storeId));
122121

122+
$ordersRootId = $this->systemConfig->getCommerceAccountId($storeId) ?: $this->systemConfig->getPageId($storeId);
123123
$ordersData = $this->graphAPIAdapter->getOrders($ordersRootId, $cursorAfter);
124124

125125
$this->ordersPulledTotal += count($ordersData['data']);
@@ -158,14 +158,14 @@ public function pullOrders(int $storeId, $cursorAfter = false)
158158
* @return array Associative array containing the refund details with Facebook Order IDs as keys.
159159
* @throws GuzzleException
160160
*/
161-
public function pullRefundOrders(int $storeId)
161+
public function pullRefundOrders(int $storeId): array
162162
{
163-
$ordersRootId = $this->systemConfig->getCommerceAccountId($storeId) ?: $this->systemConfig->getPageId($storeId);
164163
$this->graphAPIAdapter
165164
->setDebugMode($this->systemConfig->isDebugMode($storeId))
166165
->setAccessToken($this->systemConfig->getAccessToken($storeId));
167166

168167
// Pull orders with refunds
168+
$ordersRootId = $this->systemConfig->getCommerceAccountId($storeId) ?: $this->systemConfig->getPageId($storeId);
169169
$ordersWithRefunds = $this->graphAPIAdapter->getOrders(
170170
$ordersRootId,
171171
false,
@@ -202,14 +202,14 @@ public function pullRefundOrders(int $storeId)
202202
* @return array Associative array containing the cancellation details with Facebook Order IDs as keys.
203203
* @throws GuzzleException
204204
*/
205-
public function pullCancelledOrders(int $storeId)
205+
public function pullCancelledOrders(int $storeId): array
206206
{
207-
$ordersRootId = $this->systemConfig->getCommerceAccountId($storeId) ?: $this->systemConfig->getPageId($storeId);
208207
$this->graphAPIAdapter
209208
->setDebugMode($this->systemConfig->isDebugMode($storeId))
210209
->setAccessToken($this->systemConfig->getAccessToken($storeId));
211210

212211
// Pull orders with cancellations
212+
$ordersRootId = $this->systemConfig->getCommerceAccountId($storeId) ?: $this->systemConfig->getPageId($storeId);
213213
$ordersWithCancellations = $this->graphAPIAdapter->getOrders(
214214
$ordersRootId,
215215
false,

0 commit comments

Comments
 (0)