Skip to main content

How to include product category in the Order Administrator Notification

More
4 years 4 months ago #341751 by a2zcs
-- 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.

More
4 years 4 months ago #341755 by nicolas
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:
Code:
if(!empty($item->images[0]->file_path) && $config->get('thumbnail', 1) != 0) {
Just before that line, you can add that code:
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.

More
4 years 4 months ago - 4 years 4 months ago #341762 by a2zcs
Hi,
Unfortunately, it doesn't seem to be working.
Last edit: 4 years 4 months ago by a2zcs.

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

More
4 years 4 months ago #341774 by nicolas
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.

More
4 years 4 months ago #341810 by a2zcs
Hi thank you,
Here are those screen shots

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

More
4 years 4 months ago #341811 by nicolas
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:
Code:
$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.223 seconds
Powered by Kunena Forum