| @@ -155,8 +155,18 @@ | ||
| 155 | 155 | { |
| 156 | 156 | return $this->belongsTo(ProductDownload::class, 'post_id', 'post_id'); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | + /** | |
| 160 | + * All reviews of the product this line item points to — keyed on | |
| 161 | + * post_id, not on the item itself, so whereDoesntHave() over it | |
| 162 | + * expresses "the customer never reviewed this product". | |
| 163 | + */ | |
| 164 | + public function product_reviews() | |
| 165 | + { | |
| 166 | + return $this->hasMany(ProductReview::class, 'post_id', 'post_id'); | |
| 167 | + } | |
| 168 | + | |
| 159 | 169 | public function createItem($orderItems) |
| 160 | 170 | { |
| 161 | 171 | return $this->belongsTo(ProductVariation::class, 'variation_id', 'id'); |
| 162 | 172 | } |
| @@ -257,17 +267,14 @@ | ||
| 257 | 267 | * @return string |
| 258 | 268 | */ |
| 259 | 269 | public function getVariationDisplayTitleAttribute() |
| 260 | 270 | { |
| 261 | - $itemAttributes = Arr::get($this->other_info, 'item_attributes', []); | |
| 262 | - $attributesTitle = \FluentCart\App\Helpers\AttributeHelper::getDisplayAttributesString($itemAttributes, $this, 'order_item'); | |
| 263 | - | |
| 264 | - if (!$attributesTitle) { | |
| 265 | - if ($this->post_title === $this->title) { | |
| 266 | - return ''; | |
| 267 | - } | |
| 268 | - return (string)$this->title; | |
| 269 | - } | |
| 270 | - | |
| 271 | - return $attributesTitle; | |
| 271 | + // Order items carry the item_attributes snapshot (written at order | |
| 272 | + // creation), so resolve directly — getDisplayAttributesString renders | |
| 273 | + // the labeled combination and falls back to the variation title. | |
| 274 | + return \FluentCart\App\Helpers\AttributeHelper::getDisplayAttributesString( | |
| 275 | + Arr::get($this->other_info, 'item_attributes', []), | |
| 276 | + $this, | |
| 277 | + 'order_item' | |
| 278 | + ); | |
| 272 | 279 | } |
| 273 | 280 | } |