fix(ecommerce): 비회원 주문 상세의 상품별 배송정책 표시 누락 해소
비회원 주문 조회 상세는 회원 상세와 같은 화면 구성(partial)을 쓰는데 비회원 응답에만 배송정책 스냅샷이 없어 그 줄만 조용히 비어 있었다. 오류도 빈 값 표기도 없이 항목 자체가 사라지므로 응답을 열어 보기 전에는 드러나지 않는다. 스냅샷 전체를 그대로 내보내면 원가·계산 근거까지 비회원에게 노출되므로 ShippingPolicySnapshot::forDisplay 로 화면이 쓰는 정책명·개별 배송비만 추려 내보낸다. 내부 계산 정보는 종전대로 제공하지 않는다.
This commit is contained in:
1 parent
e426498fb3
commit
1ce434e2da
5 files changed
+167
-1
No files matched your search
@@ -145,6 +145,48 @@ class ShippingPolicySnapshot
|
||||
return $map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 화면 표시에 필요한 필드만 남긴 스냅샷을 만듭니다.
|
||||
*
|
||||
* 주문 상세의 배송정책 블록(`partials/mypage/orders/_items.json`)이 읽는 것은
|
||||
* `product_option_id` 와 `policy.policy_name` · `policy.standalone_shipping_amount`
|
||||
* (+ 포맷) 뿐이다. 비회원 응답은 정책 id·계산 근거 같은 내부 값을 내보내지 않으면서도
|
||||
* 이 블록이 그려지도록 표시용 필드만 추린다.
|
||||
*
|
||||
* 배송지 메타(`address`)는 표시 대상이 아니므로 제외한다 — 화면은 별도 배송지 블록에서
|
||||
* 주문 주소를 쓴다.
|
||||
*
|
||||
* `items` 는 프론트가 `.find(...)` 로 순회하므로 **항상 리스트**여야 한다.
|
||||
*
|
||||
* @param array|null $snapshot 원본 스냅샷 (신형 · 구형 모두 허용)
|
||||
* @return array{items: array<int, array>} 표시용 스냅샷
|
||||
*
|
||||
* @since 1.0.5
|
||||
*/
|
||||
public static function forDisplay(?array $snapshot): array
|
||||
{
|
||||
$items = [];
|
||||
|
||||
foreach (self::items($snapshot) as $entry) {
|
||||
if (! isset($entry['product_option_id'], $entry['policy']) || ! is_array($entry['policy'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$policy = $entry['policy'];
|
||||
|
||||
$items[] = [
|
||||
'product_option_id' => $entry['product_option_id'],
|
||||
'policy' => [
|
||||
'policy_name' => $policy['policy_name'] ?? '',
|
||||
'standalone_shipping_amount' => $policy['standalone_shipping_amount'] ?? 0,
|
||||
'standalone_shipping_amount_formatted' => $policy['standalone_shipping_amount_formatted'] ?? '',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
return [self::ITEMS => $items];
|
||||
}
|
||||
|
||||
/**
|
||||
* 지정한 옵션 ID 집합에 해당하는 항목만 추립니다.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user