Undefined variable $optionValue in view.raw.php

  • Christoph
  • Topic Author
  • Offline
  • New Member
  • New Member
More
1 day 8 hours ago - 1 day 8 hours ago #174818 by Christoph
Hello,

May be I noticed a small bug in EShop 4.0.3?

In the file components/com_eshop/views/product/view.raw.php inside the display() method of EShopViewProduct, the variable $optionValue is assigned at the end:

$this->option_value = $optionValue;

However, $optionValue is only defined inside the foreach ($options as $productOptionId => $optionValue) loop.
If no product options are set, the loop never runs, and $optionValue is undefined.

This causes the following warning:Warning: Undefined variable $optionValue in .../components/com_eshop/views/product/view.raw.php on line 290

Fix: Initialize the variable before the loop, just like the other option variables:

$optionSku = '';
$optionQuantity = '';
$optionWeight = 0;
$optionPrice = 0;
$optionValue = null; // <--- add this line

This resolves the warning and keeps $this->option_value consistent.
Or have I overlooked something?

Best regards,
Christoph

 
Last edit: 1 day 8 hours ago by Christoph.

Please Log in or Create an account to join the conversation.

Moderators: Giang Dinh Truong