Enforce Shopify order identifier handoff

This commit is contained in:
2026-08-12 17:53:26 +02:00
parent a6454c733f
commit 727025da88
2 changed files with 14 additions and 4 deletions
@@ -171,13 +171,18 @@ function shopify_projection_stock_check(PDO $pdo, array $resolvedLines): void
}
}
function project_shopify_order(PDO $pdo, array $order, array $env, bool $dryRun = true): array
function project_shopify_order(PDO $pdo, string $orderGid, callable $orderLoader, bool $dryRun = true): array
{
$orderGid = trim((string) ($order['id'] ?? ''));
$orderGid = trim($orderGid);
if ($orderGid === '') {
throw new RuntimeException('Shopify Order-GID fehlt');
}
$order = $orderLoader($orderGid);
if (!is_array($order) || (string) ($order['id'] ?? '') !== $orderGid) {
throw new RuntimeException("Shopify order {$orderGid} konnte nicht geladen werden");
}
$existingStmt = $pdo->prepare('SELECT id FROM sales_order WHERE shopify_order_gid = :shopify_order_gid LIMIT 1');
$existingStmt->execute([':shopify_order_gid' => $orderGid]);
$existingId = $existingStmt->fetchColumn();