Item-field validation error in cart->addProduct surfaces at later checkout steps

  • Posts: 41
  • Thank you received: 4
  • Hikashop Business
2 hours 30 minutes ago #371669

-- HikaShop version -- : 6.4.1
-- Joomla version -- : 6.1.0
-- PHP version -- : 8.5.5
-- Browser(s) name and version -- : Chromium 130 (Playwright) — also reproduces in any browser; not browser-specific
-- Error-message(debug-mod must be tuned on) -- : no Joomla error log entry — the bug is incorrect message routing, not a PHP error. The customer sees the field's `errormessage` value, e.g. "Please enter the year. If year does not apply, enter the word 'none'."

Hi HikaShop team,

Reporting a small bug in the standard checkout, with a suggested patch.

Bug: when

cart::addProduct()
validates a required item-field that's empty, the field's
errormessage
is written to Joomla's session message queue. The customer then sees that alert at a later checkout step (typically Payment), with no cart-row context to indicate where the error came from.

Cause: in
administrator/components/com_hikashop/classes/cart.php
line 1845,
checkFieldsData($fields, $p['fields'], $data, 'item', $oldData)
runs without overriding the field class's default
$report = true
, so
hikashopFieldClass::check()
calls
$app->enqueueMessage()
. The cart's own
addMessage($cart, ...)
loop a few lines below already handles error reporting in the right scope — the
enqueueMessage
call is redundant and leaks the message into the session queue.

The Fields-step helper at
helpers/checkout/fields.php:105
already does this correctly for order fields by passing
'msg'
as the report mode. The cart's item-field path just needs the same treatment.

Patch (against 6.4.1;
addProduct
is byte-identical to 6.4.0):
--- a/administrator/components/com_hikashop/classes/cart.php
+++ b/administrator/components/com_hikashop/classes/cart.php
@@ -1843,7 +1843,11 @@
                 }

                 $data = new stdClass();
+                $previousReport = $this->fieldClass->report;
+                $this->fieldClass->report = 'msg';
                 $ok = $this->fieldClass->checkFieldsData($fields, $p['fields'], $data, 'item', $oldData);
+                $this->fieldClass->report = $previousReport;

                 if(!$ok) {
                     unset($p['fields']);

Tested locally on Joomla 6.1.0 + HikaShop 6.4.1.

I searched the forum for prior reports of this specific symptom and didn't find one — apologies if I missed it.

Thanks,
Brian

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

Time to create page: 0.042 seconds
Powered by Kunena Forum