$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>woocommerce offtopic - Custom email template for a specific product category|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

woocommerce offtopic - Custom email template for a specific product category

matteradmin10PV0评论

I am stuck in a situation where the requirement is to create a custom email template for a particular product category, so that when any user buy product from that category he/she get that customised order email. Please help if anyone have any idea about how this can be achieved. Thanks in advance.

I am stuck in a situation where the requirement is to create a custom email template for a particular product category, so that when any user buy product from that category he/she get that customised order email. Please help if anyone have any idea about how this can be achieved. Thanks in advance.

Share Improve this question asked Jun 15, 2017 at 10:14 Pankaj ThakurPankaj Thakur 11 silver badge2 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 2

Firstly extend WC_Email class to define the email header, subject, email template for content

secondly, add custom email class to the default WooCommerce email classes using woocommerce_email_classes filter, with trigger that calls terms

if ( has_term( 'Your Cat', 'product_cat', $item['product_id'] ) )

lastly, Create an email template to be used to generate email content for your custom email.

this answer to this question involves a lot of code, far too much for SO so you may want to do some reading like.

https://cloudredux/adding-sending-custom-woocommerce-email/

Whatever plugin you're using for ecommerce, there should be an email hook available to customize the emails.

For example, WooCommerce provides 9 different hooks in its "new order" email. Here's a visual reference.

Add a function that runs on the desired hook, and you can add conditional content. You'll have to find a way to identify "any product from a particular category" - pull order details, loop through the products, and if any of them is from that category, trigger your conditional content.

Further related reading: https://tommcfarlin/customizing-woocommerce-emails-hooks/

Post a comment

comment list (0)

  1. No comments so far