How to include product category in the Order Administrator Notification

  • Posts: 248
  • Thank you received: 7
  • Hikamarket Frontedition Hikamarket Multivendor Hikaserial Standard Hikashop Business
2 years 2 days ago #341751

-- url of the page with the problem -- : blessedsacramentlibrary.org/
-- HikaShop version -- : 4.5.1
-- Joomla version -- : 4.1.3
-- PHP version -- : 7.4.29
-- Browser(s) name and version -- : Chrome
-- Error-message(debug-mod must be tuned on) -- : none

Hi,
I can see where I can add the tags for many other fields in the notification, but not for the category of an item.
Is this possible? how?
Thanks

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

  • Posts: 81703
  • Thank you received: 13104
  • MODERATOR
2 years 2 days ago #341755

Hi,

The data of the categories of each product is loaded but not available as tags.
When you edit an email in the menu System>Emails, you have a "preload" area at the bottom of the edit interface.
There, you have the line:

if(!empty($item->images[0]->file_path) && $config->get('thumbnail', 1) != 0) {
Just before that line, you can add that code:
$categories = array();
foreach($product->categories as $cat) {
 $categories[] = hikashop_translate($cat->category_name);
}
$cartProduct['CATEGORIES'] = implode(' / ', $categories);
And then you'll be able to use the tag {LINEVAR:CATEGORIES} in the HTML area of the email.

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

  • Posts: 248
  • Thank you received: 7
  • Hikamarket Frontedition Hikamarket Multivendor Hikaserial Standard Hikashop Business
2 years 2 days ago #341762

Hi,
Unfortunately, it doesn't seem to be working.

Last edit: 2 years 1 day ago by a2zcs.

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

  • Posts: 81703
  • Thank you received: 13104
  • MODERATOR
2 years 1 day ago #341774

Hi,

where did you add the tag in the HTML ? And could you provide a screenshot of the area where you added the code in the preload ?

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

  • Posts: 248
  • Thank you received: 7
  • Hikamarket Frontedition Hikamarket Multivendor Hikaserial Standard Hikashop Business
2 years 19 hours ago #341810

Hi thank you,
Here are those screen shots

Attachments:

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

  • Posts: 81703
  • Thank you received: 13104
  • MODERATOR
2 years 16 hours ago #341811

Hi,

Thanks.
I looked into it and the issue is that in $product->categories, it's only an array of category ids where I thought it was the whole category object.
So you should use instead this code in the preload:

$categories = array();
$categoryClass = hikashop_get('class.category');
foreach($product->categories as $cat) {
 $category = $categoryClass->get($cat);
 $categories[] = hikashop_translate($category->category_name);
}
$cartProduct['CATEGORIES'] = implode(' / ', $categories);

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

Time to create page: 0.072 seconds
Powered by Kunena Forum