Hikashop - Message from an Order

  • Posts: 42
  • Thank you received: 1
  • Hikamarket Multivendor Hikashop Business
1 week 2 days ago #371519

-- HikaShop version -- : 6.3.0
-- Joomla version -- : 5.4.2

Hello

I'm validating transactional emails for Hikashop, and one isn't working. When a user makes a purchase, they can access the order details page, which they can also access from their user profile. On that page, they have the option to send a message or ask a question by clicking the "Contact us about your order" button. When they click the button, a form opens to send a message. I assume the message is directed to the seller of the purchased order, but the email never arrives. I've checked the spam folders and run several tests, but it's still not getting through.

Could you explain how to validate this email and how to fix it?

Thanks!

Attachments:

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

  • Posts: 85507
  • Thank you received: 13986
  • MODERATOR
1 week 2 days ago #371521

Hi,

There are two things you can do in priority:
- In System>Emails, you can see the list of emails HikaShop can send. There, you'll find the "Contact request" email. Make sure it is published. If not, the email won't be sent. Also, you can open it and use the "preview" button to check that the email can be generated by HikaShop.
- In Customers>Emails history, you can see the list of emails sent / generated by HikaShop. If you see the emails there but you don't receive them, it's likely a problem with either the settings of the Emails section of the Joomla configuration page, or with the settings of the Emails section of the HikaShop configuration page.

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

  • Posts: 42
  • Thank you received: 1
  • Hikamarket Multivendor Hikashop Business
1 week 1 day ago #371534

Hello

I found the email in System > Emails, but I also discovered that the message is going to the site administrator's inbox, when it should be going to the inbox of the salesperson associated with the order.

How can I change the recipient?

Last edit: 1 week 1 day ago by nmacri.

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

  • Posts: 85507
  • Thank you received: 13986
  • MODERATOR
1 week 1 day ago #371537

Hi,

The email goes to the email address you specify in the "Contact request email address" setting of the HikaShop configuration. You can change that setting, but you can't have it dynamic.
How is the salesperson associated with the order ?
That would probably require some kind of customization in System>Emails in order to override the email address of the recipient.

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

  • Posts: 42
  • Thank you received: 1
  • Hikamarket Multivendor Hikashop Business
1 week 17 hours ago #371542

Hello

But we agree that this isn't right, right?

On the one hand, if it's a multi-vendor e-commerce site, the site administrator can't possibly respond to inquiries from 100 or 1000 vendors; it's simply not feasible.

On the other hand, the user making the purchase has no way to communicate with the actual vendor, such as how to coordinate product delivery, payment, etc.

Can you make the change you mentioned?
Or at least give me instructions on which files I need to customize and whether I have access to the vendor object within them, which I understand contains the vendor's email address?

Thanks!

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

  • Posts: 85507
  • Thank you received: 13986
  • MODERATOR
1 week 7 hours ago #371544

Hi,

1. You had not mentioned this was a multivendor website and that a vendor is a salesperson on your website.

2. The current HikaMarket version doesn't have anything to allow the customer to directly contact the vendor from the order page. But that's a good idea. We'll look at improving this for the next version of HikaMarket.

3. If you can't wait, you can directly change the behavior of the email as I was hinting at in my previous message.
In System>Emails, you can edit the "contact request" email. There, in the preload section, you have access to the order data in $data. And you have access to the email data in $mail
While $data won't directly contain the vendor data, you'll have the order id in $data->order->order_id and you can use something like that:

if(!empty($data->order)
      && !empty($data->order->order_type) && $data->order->order_type == 'subsale'
      && !empty($data->order->order_vendor_id) && $data->order->order_vendor_id > 1
      && class_exists('hikamarket')) {
      $vendorClass = hikamarket::get('class.vendor');
      $vendor = $vendorClass->get((int)$data->order->order_vendor_id);
      if(!empty($vendor) && !empty($vendor->vendor_published) && !empty($vendor->vendor_email)) {
          $mail->dst_email = $vendor->vendor_email;
          $mail->dst_name  = $vendor->vendor_name;
      }
  }

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

  • Posts: 42
  • Thank you received: 1
  • Hikamarket Multivendor Hikashop Business
1 week 49 minutes ago #371564

Hello,

I apologize for the confusion. Since I have been making several inquiries regarding Hikashop and HikaMarket, I inadvertently forgot to mention that I am using both extensions together.

Regarding the solution you provided—which I appreciate—after further analysis, I’ve noticed that the "Contact request" email is being triggered in two similar but distinct scenarios:

First scenario (the one that prompted this inquiry): A user places an order and, from the order details page, sends a query to the vendor. In this case, the email subject follows the configuration in System -> Emails, and the message is delivered to the email account configured in the Hikashop administration (the ecommerce administrator's address).

Second scenario: A guest user (not logged in) visits a specific product and submits a query about it. In this case, the email subject is "Contact request for order" (translation key: CONTACT_REQUEST_FOR_ORDER), and the message is delivered to the product vendor's email account.

It strikes me as unusual that if the same code is used to generate the email and the same preload code is applied, the messages are sent to different destinations.

Could you please look into this? I might be misinterpreting something, but I added custom text to the email body (to the code itself, NOT the template), and that text appears in both types of messages.

Thank you very much for your help, and sorry for the long explanation!

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

  • Posts: 85507
  • Thank you received: 13986
  • MODERATOR
6 days 4 hours ago #371569


It strikes me as unusual that if the same code is used to generate the email and the same preload code is applied, the messages are sent to different destinations.

Could you please look into this?

This is normal. HikaMarket already comes with some code to override the contact request email, but only for the product page, in order to send the email to the vendor instead of the shop owner.

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

  • Posts: 42
  • Thank you received: 1
  • Hikamarket Multivendor Hikashop Business
2 days 14 hours ago #371641

Hi

Perfect, I understand that's the normal behavior.

So, I tried adding the code block you shared in a previous post to load the seller's email as the message recipient. I've attached the complete code from the preload section. Is it correct to add it at the end? Because it's not working; the message is still being sent to the email address configured in the Hikashop admin panel.

Thanks!

<?php
/**
 * @package	HikaShop for Joomla!
 * @version	6.3.0
 * @author	hikashop.com
 * @copyright	(C) 2010-2026 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php
global $Itemid;
$url_itemid = '';
if(!empty($Itemid)) {
	$url_itemid = '&Itemid=' . $Itemid;
}

$texts = array(
	'MAIL_HEADER' => JText::_('HIKASHOP_MAIL_HEADER'),
	'CONTACT_TITLE' => JText::_('CONTACT_EMAIL_TITLE'),
	'CONTACT_BEGIN_MESSAGE' => JText::_('CONTACT_BEGIN_MESSAGE'),
	'USER_MESSAGE' => JText::_('CONTACT_USER_MESSAGE'),
	'USER' => JText::_('HIKA_USER'),
	'HI_USER' => JText::sprintf('HI_CUSTOMER', ''),
	'FOR_PRODUCT' => '',
);

$vars = array(
	'LIVE_SITE' => HIKASHOP_LIVE,
	'URL' => HIKASHOP_LIVE,
	'PRODUCT_DETAILS' => '',
	'FRONT_PRODUCT_DETAILS' => '',
	'PRODUCT' => false,
);

$main_element = null;
if(!empty($data->order)) {
	$texts['FOR_PRODUCT'] = JText::sprintf('CONTACT_REQUEST_FOR_ORDER', $data->order->order_number);

	$admin_url = JRoute::_('administrator/index.php?option=com_hikashop&ctrl=order&task=show&cid[]='.$data->order->order_id, false, true);
	$front_url = hikashop_frontendLink('index.php?option=com_hikashop&ctrl=order&task=show&cid='.$data->order->order_id.'&order_token='.$data->order->order_token.$url_itemid);
	$element_name = $data->order->order_number;
	$texts['PRODUCT'] = JText::_('HIKASHOP_ORDER');
	$vars['PRODUCT'] = true;
	$main_element = $data->order;
} elseif(!empty($data->product)) {
	$texts['FOR_PRODUCT'] = JText::sprintf('CONTACT_REQUEST_FOR_PRODUCT', $data->product->product_name);

	$admin_url = JRoute::_('administrator/index.php?option=com_hikashop&ctrl=product&task=edit&cid[]='.$data->product->product_id, false, true);
	$productClass = hikashop_get('class.product');
	$productClass->addAlias($data->product);
	$front_url = hikashop_frontendLink('index.php?option=com_hikashop&ctrl=product&task=show&cid='.$data->product->product_id.'&name='.$data->product->alias.$url_itemid);
	$element_name = strip_tags($data->product->product_name.' ('.$data->product->product_code.')');
	$texts['PRODUCT'] = JText::_('PRODUCT');
	$vars['PRODUCT'] = true;
	$main_element = $data->product;
}

$name = '';
if(!empty($data->element->email)) {
	$name = $data->element->email;
}
if(!empty($data->element->name)) {
	if(empty($name))
		$name = $data->element->name;
	else
		$name = $data->element->name.' ( '. $name . ' )';
}
if(!empty($name)) {
	$vars['USER_DETAILS'] = htmlentities($name, ENT_COMPAT, 'UTF-8');

}
$vars['USER'] = !empty($name);

if(!empty($data->element->altbody)) {
	$vars['USER_MESSAGE'] = str_replace(array("\r\n","\r","\n"), '<br/>', $data->element->altbody);
}

$vars['MESSAGE'] = !empty($data->element->altbody);

if(!empty($element_name)) {
	$vars['PRODUCT_DETAILS'] = '<p>'.$element_name;
	if(!empty($admin_url))
		$vars['PRODUCT_DETAILS'] .= ' <a href="'.$admin_url.'">'.JText::_('BACKEND_EDITON_PAGE').'</a>';
	if(!empty($front_url))
		$vars['PRODUCT_DETAILS'] .= ' <a href="'.$front_url.'">'.JText::_('FRONTEND_DETAILS_PAGE').'</a>';
	$vars['PRODUCT_DETAILS'] .= '</p>';
}

if(hikashop_level(1)) {
	$fieldsClass = hikashop_get('class.field');
	$contactFields = $fieldsClass->getFields('frontcomp',$main_element,'contact');
	if(!empty($contactFields)){
		foreach($contactFields as $field){
			$namekey = $field->field_namekey;
			if(!isset($data->element->$namekey)) continue;
			if(empty($data->element->$namekey) && !strlen($data->element->$namekey)) continue;
			$field->currentElement = $data->element;
			$vars['PRODUCT_DETAILS'] .= '<p>'.$fieldsClass->getFieldName($field).': '.$fieldsClass->show($field, $data->element->$namekey, 'admin_email').'</p>';
		}
		if(!empty($vars['PRODUCT_DETAILS']))
			$vars['PRODUCT'] = true;
	}
}


if(!empty($data->order) 
      && !empty($data->order->order_type) && $data->order->order_type == 'subsale' 
      && !empty($data->order->order_vendor_id) && $data->order->order_vendor_id > 1 
      && class_exists('hikamarket')) { 
      $vendorClass = hikamarket::get('class.vendor'); 
      $vendor = $vendorClass->get((int)$data->order->order_vendor_id); 
      if(!empty($vendor) && !empty($vendor->vendor_published) && !empty($vendor->vendor_email)) { 
          $mail->dst_email = $vendor->vendor_email; 
          $mail->dst_name = $vendor->vendor_name; 
      } 
  }

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

  • Posts: 85507
  • Thank you received: 13986
  • MODERATOR
2 days 1 hour ago #371645

Hi,

Note that the code is not tested. That's something I've written on the fly. It needs proper testing and potentially some changes.

However, since then, we've released HikaMarket 6.1.0:
www.hikashop.com/support/documentation/1...arket-changelog.html
And one of the main features of that new version is:

Customers can now contact each vendor of their order directly. A dedicated "Contact vendor" entry is added to the HikaShop order details toolbar, to the orders listing action dropdown, and to the order block on the user control panel. Each link opens the HikaShop contact form targeting the relevant vendor sub-order, and the email is automatically routed to that vendor's address. The contact form title is rewritten to reference the parent order number for clarity.

So, I would recommend updating your HikaMarket and avoiding this customization.

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

Time to create page: 0.067 seconds
Powered by Kunena Forum