How to include product category in the Order Administrator Notification

  • Posts: 248
  • Thank you received: 7
  • Hikamarket Frontedition Hikamarket Multivendor Hikaserial Standard Hikashop Business
1 year 11 months 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: 81540
  • Thank you received: 13070
  • MODERATOR
1 year 11 months 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
1 year 11 months ago #341762

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

Last edit: 1 year 11 months ago by a2zcs.

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

  • Posts: 81540
  • Thank you received: 13070
  • MODERATOR
1 year 11 months 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
1 year 11 months ago #341810

Hi thank you,
Here are those screen shots

Attachments:

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

  • Posts: 81540
  • Thank you received: 13070
  • MODERATOR
1 year 11 months 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.064 seconds
Powered by Kunena Forum