Send Notification Email" checkbox forces email sending even when unchecked

  • Posts: 6
  • Thank you received: 1
  • Hikashop Business
6 days 15 hours ago #372391

-- HikaShop version -- : 6.5.0
-- Joomla version -- : 6.1.1
-- PHP version -- : 8.4.19

Hello HikaShop team,

I'm currently using HikaShop Business v6.4.1 (on Joomla 6.1.1) and I have found a bug when using the Order Mass Actions (batch process from the Orders Listing).

When I select one or multiple orders, click the "Actions" button, choose "Change status" and explicitly uncheck the "Send notification email" checkbox, the email is still being sent to the customers.

Upon debugging, we found that the issue is located in the massaction_order plugin (plugins/hikashop/massaction_order/massaction_order.php). In the onProcessOrderMassActionchangeStatus function, the code checks for the existence of the notify variable using isset():

// Around line 535

if(isset($action)){
if(!isset($element->history) || !is_object($element->history))
$element->history = new stdClass();
$element->history->history_notified = 1;
}

Because the DOM/form can submit an empty value or "0" when the checkbox is unchecked, isset() evaluates to true and blindly forces $element->history->history_notified = 1, completely ignoring the unchecked state.

Possible Fix: : Changing the validation from isset to !empty and explicitly forcing 0 when false solves the problem completely:

if(!empty($action)){
if(!isset($element->history) || !is_object($element->history))
$element->history = new stdClass();
$element->history->history_notified = 1;
} else {
if(!isset($element->history) || !is_object($element->history))
$element->history = new stdClass();
$element->history->history_notified = 0;
}

Could you please verify if my observation is correct? I would appreciate it if you could let me know if this proposed solution is the right approach to fix it.

Thank you for your time!

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

  • Posts: 85796
  • Thank you received: 14089
  • MODERATOR
6 days 10 hours ago #372393

Hi,

Confirmed, and thank you for the precise report. The test in onProcessOrderMassActionchangeStatus is indeed too loose:

if(isset($action['notify'])){
	...
	$element->history->history_notified = 1;
}

The change-status mass action renders the notification checkbox without a hidden 0 companion, and the action data is initialised with 'notify' => '' (empty string), so the key can be present but empty. isset() treats that as true and forces history_notified = 1 even when the box is unchecked. The single-order save uses !empty($data) for exactly this reason, and the mass action should do the same.

So the minimal fix is just isset -> !empty:
if(!empty($action['notify'])){
	if(!isset($element->history) || !is_object($element->history))
		$element->history = new stdClass();
	$element->history->history_notified = 1;
}

Your version with the explicit else setting history_notified = 0 works too, it just makes the unchecked case explicit; it is not required, since the order save leaves the notification off when the flag is not set.

We will include the fix on our end in the next version.

The following user(s) said Thank You: UPL

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

  • Posts: 6
  • Thank you received: 1
  • Hikashop Business
6 days 10 hours ago #372396

Thank you very much for the quick confirmation, Nicolas!

We are glad to hear that the report was helpful and that the fix will be included in the next official release. Keep up the great work with HikaShop!

Best regards.

The following user(s) said Thank You: nicolas

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

Time to create page: 0.055 seconds
Powered by Kunena Forum