| @@ -1,13 +1,11 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace FluentCart\App\Services\Renderer; |
| 4 | 4 | |
| 5 | -use FluentCart\App\Helpers\AttributeHelper; | |
| 6 | 5 | use FluentCart\App\Helpers\Helper; |
| 7 | 6 | use FluentCart\App\Models\Cart; |
| 8 | 7 | use FluentCart\Framework\Support\Arr; |
| 9 | -use FluentCart\App\Vite; | |
| 10 | 8 | |
| 11 | 9 | class CartItemRenderer |
| 12 | 10 | { |
| 13 | 11 | protected $item = []; |
| @@ -108,16 +106,12 @@ | ||
| 108 | 106 | $href = Arr::get($this->item, 'view_url', ''); |
| 109 | 107 | |
| 110 | 108 | $mainTitle = (string) Arr::get($this->item, 'post_title', ''); |
| 111 | 109 | |
| 112 | - // Prefer the labeled attribute combination ("Color: Red | Size: XS") | |
| 113 | - // when the item carries an attribute snapshot; fall back to the raw | |
| 114 | - // variation title for custom/simple items. | |
| 115 | - $itemAttributes = (array) Arr::get($this->item, 'other_info.item_attributes', []); | |
| 116 | - $attributesText = $itemAttributes | |
| 117 | - ? AttributeHelper::getDisplayAttributesString($itemAttributes, $this->item, 'cart') | |
| 118 | - : ''; | |
| 119 | - $subtitle = $attributesText !== '' ? $attributesText : (string) Arr::get($this->item, 'title', ''); | |
| 110 | + // The Cart model already resolves & appends variation_display_title on | |
| 111 | + // every cart item (Cart::getCartDataAttribute); fall back to the raw | |
| 112 | + // variation title for items it didn't decorate. | |
| 113 | + $subtitle = (string) Arr::get($this->item, 'variation_display_title', (string) Arr::get($this->item, 'title', '')); | |
| 120 | 114 | |
| 121 | 115 | $quantity = Arr::get($this->item, 'quantity', 1); |
| 122 | 116 | |
| 123 | 117 | ?> |
| @@ -158,11 +152,10 @@ | ||
| 158 | 152 | |
| 159 | 153 | public function renderImage() |
| 160 | 154 | { |
| 161 | 155 | $image = Arr::get($this->item, 'featured_media'); |
| 162 | - if (!$image) { | |
| 163 | - $image = Vite::getAssetUrl('images/placeholder.svg'); | |
| 164 | - } | |
| 156 | + // Also maps the old generic icon a pre-existing cart row may still store. | |
| 157 | + $image = Helper::productImageOrPlaceholder($image); | |
| 165 | 158 | $href = Arr::get($this->item, 'view_url', ''); |
| 166 | 159 | $altText = sprintf( |
| 167 | 160 | /* translators: %s: product title */ |
| 168 | 161 | __('Image of %s', 'fluent-cart'), Arr::get($this->item, 'title', __('product', 'fluent-cart'))); |