Fix: Updates to OrderFullfilmentServices and box now clients, order views and checkout services
This commit is contained in:
@@ -67,7 +67,7 @@ class BoxNowFulfillmentService implements CarrierFulfillmentInterface, SupportsT
|
||||
'locationId' => config('boxnow.origin_location_id'),
|
||||
],
|
||||
'destination' => [
|
||||
'contactNumber' => $address->contact_phone,
|
||||
'contactNumber' => $this->internationalPhone($address->contact_phone),
|
||||
'contactEmail' => $address->contact_email,
|
||||
'contactName' => trim("{$address->first_name} {$address->last_name}"),
|
||||
'locationId' => $destinationLocationId,
|
||||
@@ -105,6 +105,37 @@ class BoxNowFulfillmentService implements CarrierFulfillmentInterface, SupportsT
|
||||
return $shipments->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Box Now rejects any contactNumber not in full international format
|
||||
* (error P405 — confirmed in practice: a plain Greek mobile like
|
||||
* "6955994563" 400s with {"code":"P405"}). Checkout collects phone
|
||||
* numbers in local format, with no international-format enforcement of
|
||||
* its own — this store is Greece-only (see CheckoutController::
|
||||
* STORE_COUNTRY_ISO3), so a bare local number is assumed Greek and
|
||||
* prefixed accordingly, same convention ACS's own sender config already
|
||||
* uses (config('boxnow.sender.phone') is documented as "+30..." there
|
||||
* too). A number already carrying a country code (leading "+" or "00")
|
||||
* is passed through unchanged.
|
||||
*/
|
||||
private function internationalPhone(?string $phone): ?string
|
||||
{
|
||||
if ($phone === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$digitsOnly = preg_replace('/[^\d+]/', '', $phone);
|
||||
|
||||
if (str_starts_with($digitsOnly, '+')) {
|
||||
return $digitsOnly;
|
||||
}
|
||||
|
||||
if (str_starts_with($digitsOnly, '00')) {
|
||||
return '+'.substr($digitsOnly, 2);
|
||||
}
|
||||
|
||||
return '+30'.ltrim($digitsOnly, '0');
|
||||
}
|
||||
|
||||
public function printLabel(Shipment $shipment): string
|
||||
{
|
||||
$bytes = $this->client->requestRaw("/parcels/{$shipment->tracking_reference}/label.pdf");
|
||||
|
||||
Reference in New Issue
Block a user