Skip to content

Commit

Permalink
refact: slugyfi
Browse files Browse the repository at this point in the history
  • Loading branch information
kaioken committed Dec 24, 2024
1 parent 1ce7877 commit 9d82607
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ public function execute(Order $order, Apps $app, array $params): array

$response['order_id'] = $order->id;
$response['order'] = $order->toArray();

$sku = null;
foreach ($order->items as $item) {
$variant = Variants::where('id', $item->variant_id)->first();
$detail['variant'] = $variant->toArray();
$detail['variant']['attributes'] = $variant->attributes()->pluck('value', 'name')->toArray();
$sku = $variant->sku;

$response['items'][] = $detail;
}
Expand All @@ -77,6 +78,8 @@ public function execute(Order $order, Apps $app, array $params): array
'esim_status' => $response['data']['status'] ?? null,
'phone_number' => $response['data']['phone_number'] ?? null,
];
$response['data']['plan_origin'] = $response['data']['plan'];
$response['data']['plan'] = $sku; //overwrite the plan with the sku
}
} catch (Throwable $e) {
// Log the exception or handle it as needed
Expand Down Expand Up @@ -108,6 +111,7 @@ public function execute(Order $order, Apps $app, array $params): array
return [
'status' => 'success',
'message' => 'Order updated with eSim metadata',
'message_id' => $message->getId(),
'response' => $response,
];
}
Expand Down

0 comments on commit 9d82607

Please sign in to comment.