Order notification: Show ALL product options, not only selected ones

  • Posts: 6
  • Thank you received: 2
1 year 6 months ago #345132

-- HikaShop version -- : 4.6.1
-- Joomla version -- : 4.2.0
-- PHP version -- : 8.1.7
-- Browser(s) name and version -- : Chrome 104.0.5112.101

Dear HikaShop Team,

I want to make some changes in the "Preload-Email-Template" - but I'm missing the data I need to make my modifications and I hope you can give me a hint how to solve the problem.

The default source code is going through the ordered products and lists all the selected product options and characteristics. All UNSELECTED options/characteristics are not part of the collected data - but I need them because I want them to show, but greyed out.

I don't have problems to identify the source code row where I can add my changes, but I'm having problems to get the "not selected" checkboxes - of course because they are not part of the order (technically spoken).

Example:
I have a product with option "sauce" and four checkboxes for different sauces. If a customer is selecting 3 of the 4 checkboxes they will be shown in the order email. And now I want to add the missing checkbox "greyed out". But the fourth sauce is not part of any class/object/variable in the preload template.

How can I get these information?
Thanks in advance for your support and have a nice day :)

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

  • Posts: 81540
  • Thank you received: 13069
  • MODERATOR
1 year 6 months ago #345136

Hi,

Indeed, that data is not available in the preload.
The line:

$t .= '<p class="hikashop_order_option_name">' . $optionElement->order_product_name;
is displaying the name of the variant of the option.
So you probably want to add custom code around there to :
- load the data of the variant of the option from the hikashop_product table:
$optionVariantSelected = $productClass->get($optionElement->product_id);
- load the data of the option from the hikashop_product table:
$option = $productClass->get($optionVariantSelected->product_parent_id);
- load the data of the characteristics, values and variants of the option:
$option = $productClass->loadProductVariants($option, array('user_id' => $data->cart->order_user_id, 'selected_variant_id' => $optionElement->product_id));
- then, in $option->variants you'll have an array of all the possible choices of $option and you can compare that with the variants available in the order to do the display.

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

  • Posts: 6
  • Thank you received: 2
1 year 6 months ago #345351

Hi Nicholas,

sorry for the late reply! I just want to thank you for your support. Your posted code helped me a lot to get what I wanted.
Thanks for the effort and you can close the topic :)

Best regards!

The following user(s) said Thank You: nicolas

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

Time to create page: 0.059 seconds
Powered by Kunena Forum