Process Shopify webhooks asynchronously

This commit is contained in:
2026-08-12 18:15:24 +02:00
parent 1e75ef7a24
commit 8c4b9a7f89
5 changed files with 195 additions and 29 deletions
@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
function shopify_load_order_by_gid(array $env, string $orderGid): array
{
$query = <<<'GQL'
query ($id: ID!) {
order(id: $id) {
id name createdAt updatedAt cancelledAt displayFinancialStatus displayFulfillmentStatus
currentSubtotalPriceSet { shopMoney { amount currencyCode } }
totalShippingPriceSet { shopMoney { amount currencyCode } }
totalTaxSet { shopMoney { amount currencyCode } }
totalPriceSet { shopMoney { amount currencyCode } }
customer { id firstName lastName email phone }
billingAddress { firstName lastName company address1 address2 zip city provinceCode country countryCodeV2 phone }
shippingAddress { firstName lastName company address1 address2 zip city provinceCode country countryCodeV2 phone }
lineItems(first: 50) {
nodes { id sku name quantity originalUnitPriceSet { shopMoney { amount currencyCode } } variant { id sku product { id } } }
}
}
}
GQL;
$data = shopify_graphql_query($env, $query, ['id' => $orderGid]);
$order = $data['order'] ?? null;
if (!is_array($order)) {
throw new RuntimeException("Shopify-Bestellung nicht gefunden: {$orderGid}");
}
return $order;
}