Sending to Different Admin Emails Based on Category
-
Love the plugin! As always, clients have creative requests. I’m trying to send the “Request for New Quote” email to different admin addresses based on the category of the product(s) in the cart.
I found a similar post in this forum requesting the same thing but for the state. I used that code to try and create something similar but I am getting an error at checkout. Strangely the order/quote is processed and I can see it on the backend but no notifications are being sent and the user receives a checkout error.
Here is the code I’m using…add_filter( 'woocommerce_email_recipient_qwc_req_new_quote', 'custom_quote_email_recipient', 10, 2 ); function custom_quote_email_recipient( $recipient, $order_id ) { // Get order object from ID $order_id = $order->order_id; $wc_order_obj = wc_get_order( $order_id ); // Category slugs and emails $equipment_cat = 'equipment'; $equipment_email = '[email protected]'; $party_cat = 'party'; $party_email = '[email protected]'; // Get order items $items = $order->get_items(); // Check categories foreach ( $items as $item ) { $product = $item->get_product(); $categories = wc_get_product_category_list( $product->get_id() ); if ( in_array( $equipment_cat, $categories ) ) { $recipient = $equipment_email; break; } elseif ( in_array( $party_cat, $categories ) ) { $recipient = $party_email; break; } } return $recipient; }
I am glad to pay you to troubleshoot this with me and/or provide this customization. Thanks.
The page I need help with: [log in to see the link]
- The topic ‘Sending to Different Admin Emails Based on Category’ is closed to new replies.