Undefined variable $optionValue in view.raw.php

  • Christoph
  • Topic Author
  • Offline
  • New Member
  • New Member
More
1 month 18 hours ago - 1 month 18 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 month 18 hours ago by Christoph.

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

  • Giang Dinh Truong
  • Offline
  • Administrator
  • Administrator
More
2 weeks 4 days ago #175037 by Giang Dinh Truong
Replied by Giang Dinh Truong on topic Undefined variable $optionValue in view.raw.php
Hello Christoph,

Yes, this is a good fix. I just updated this into the code. It will be included in the next version of EShop.

Sincerely, Giang

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

Moderators: Giang Dinh Truong