php - Woocommerce - Need to send email to specific address based on zip code -


Basically, you have the option to input more than one email address (separated by commas) in woocommerce, in WooCommerce -> Settings -> Email -> New Order. But I want a way to send only one of these recipients based on the zip code of the customer ordering the product. Or overwrite woocommerce mode to manage it completely.

How do I add a functional function to send it to the right recipient? Basically, is there a hook defined for this or does a plugin exist for something like this or do I have to edit the main WooCommerce files? If editing for core files is required, can someone tell me in the right direction, which file would be required to edit?

Each email has a filter that allows you to adjust the recipients of that email. The filter name is essentially woocommerce_email_recipient _ {$ email_id} .

will filter the address "to" for the following "new_order" email

add_filter ('new_order', 'so_26429482_add_recipient', 20, 2);

function SO_26429482_add_recipient ($ email, $ command) {$ extra_email = "none @ pure"; If ($ order- & gt; shipping_post code == "90210") {$ email = explosion (',', $ email); Array_push ($ email, $ extra_mail); } $ Email returned; }

I'm not 100% sure on the conditional argument, but I think the shipping zip code should be checked and later sent to the additional email address.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -