Skip to main content

Sort by product_code in mail

More
10 years 9 months ago #223610 by Squashtoppertje
-- HikaShop version -- : 2.6.0. Business

Hi,

I want to sort the products in the notification mail by product_code. How can I get this done?

Thanks!

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

More
10 years 9 months ago #223622 by Jerome
Replied by Jerome on topic Sort by product_code in mail
Hi,

It will require some custom code in your email "preload".
When you edit an email in the HikaShop backend (HikaShop business required), you have three parts (html, text, preload).

The preload is the PHP code which generate the content data for the html/text parts.
In that preload code, you will find that :
Code:
$cartProducts[] = $cartProduct; } $templates['PRODUCT_LINE'] = $cartProducts;
You need to insert the "$cartProduct" in the "$cartProducts" array but with the product code as key. So after the addition of all products in the array, you can sort the array by the array key (which will be the product code).

Regards,

Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

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

More
10 years 9 months ago #223697 by Squashtoppertje
Hi Jerome,

Thanks for your answer.

I tried the following:
Around line 120 of the preload version I changed the array code to:
Code:
//$cartProducts = array(); // ADDED FOR SORTING IN EMAIL $cartProducts = array($item->order_product_code => $cartProduct ); ksort($item->order_product_code); // END ADDITION $cartFooters = array();

But this didn't have effect in the email. Probably I did something wrong.

Can you help me a bit more?

Thanks!

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

More
10 years 9 months ago #223722 by nicolas
Hi,

Your code is not correct.
The line:
Code:
$cartProducts[] = $cartProduct;
should be replaced by:
Code:
$cartProducts[$item->order_product_code] = $cartProduct;
and then, you should add the line:
Code:
ksort($cartProducts);
before the line:
Code:
$templates['PRODUCT_LINE'] = $cartProducts;
The following user(s) said Thank You: Squashtoppertje

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

More
10 years 9 months ago #223857 by Squashtoppertje
Yes, this works. Thanks a lot!

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

Time to create page: 0.211 seconds
Powered by Kunena Forum