Skip to content

Commit 281aafd

Browse files
Enhance getVatId logic in AddressHandler
Channable may supply this value under 'vat_number' or 'vat_id'
1 parent 0e3dd26 commit 281aafd

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

Service/Order/ImportSimulator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ public function getTestData(array $params): array
185185
"country_code" => $country,
186186
"state" => $country == "US" ? "Texas" : "",
187187
"state_code" => $country == "US" ? "TX" : "",
188-
"vat_number" => "NL123456790B01"
188+
"vat_number" => "",
189+
"vat_id" => "NL123456790B01"
189190
],
190191
"shipping" => [
191192
"first_name" => "Test",

Service/Order/Quote/AddressHandler.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,18 @@ private function getVatId(string $type, array $orderData, int $storeId): ?string
161161
return null;
162162
}
163163

164-
$vatId = !empty($orderData['billing']['vat_number']) ? $orderData['billing']['vat_number'] : null;
164+
$vatId = null;
165+
166+
// Attempt to retrieve VAT ID from billing data:
167+
// Channable may supply this value under 'vat_number' or 'vat_id'.
168+
// We prefer 'vat_number' first, then fallback to 'vat_id'.
169+
foreach (['vat_number', 'vat_id'] as $vatKey) {
170+
if (isset($orderData['billing'][$vatKey]) && trim($orderData['billing'][$vatKey]) !== '') {
171+
$vatId = $orderData['billing'][$vatKey];
172+
break;
173+
}
174+
}
175+
165176
if ($type == 'billing' || !$vatId) {
166177
return $vatId;
167178
}

0 commit comments

Comments
 (0)