This commit is contained in:
2026-04-07 20:32:43 +02:00
parent 1933c74395
commit 8fa9ca6439
45 changed files with 2974 additions and 3382 deletions

View File

@@ -136,7 +136,7 @@ final class ShopproOrderMapper
'external_platform_id' => IntegrationSources::SHOPPRO,
'external_platform_account_id' => null,
'external_status_id' => $effectiveStatus,
'external_payment_type_id' => StringHelper::nullableString((string) $this->readPath($payload, ['payment_method', 'payment.method', 'payments.method'])),
'external_payment_type_id' => $this->normalizeCodPaymentType((string) $this->readPath($payload, ['payment_method', 'payment.method', 'payments.method'])),
'payment_status' => $this->mapPaymentStatus($payload, $isPaid),
'external_carrier_id' => StringHelper::nullableString($deliveryLabel),
'external_carrier_account_id' => StringHelper::nullableString((string) $this->readPath($payload, [
@@ -603,6 +603,16 @@ final class ShopproOrderMapper
}
}
$message = $this->readPath($row, ['message']);
if ($message !== null && $message !== '' && $message !== false) {
$text = str_replace(['<br>', '<br/>', '<br />'], "\n", (string) $message);
$text = html_entity_decode(strip_tags($text), ENT_QUOTES | ENT_HTML5, 'UTF-8');
$text = trim($text);
if ($text !== '') {
$parts[] = 'Wiadomość: ' . $text;
}
}
return $parts !== [] ? implode("\n", $parts) : null;
}
@@ -659,7 +669,7 @@ final class ShopproOrderMapper
*/
private function mapNotes(array $payload): array
{
$comment = StringHelper::nullableString((string) $this->readPath($payload, ['notes', 'comment', 'customer_comment']));
$comment = StringHelper::nullableString((string) $this->readPath($payload, ['notes', 'comment', 'customer_comment', 'message']));
if ($comment === null) {
return [];
}
@@ -827,6 +837,15 @@ final class ShopproOrderMapper
return null;
}
private function normalizeCodPaymentType(string $raw): ?string
{
$value = StringHelper::nullableString($raw);
if ($value === null) {
return null;
}
return StringHelper::isCodPayment($value) ? 'CASH_ON_DELIVERY' : $value;
}
private function readSinglePath(mixed $payload, string $path): mixed
{
if ($path === '') {