Advertisement
Guest User

Untitled

a guest
Feb 25th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. add_filter( 'woocommerce_email_recipient_new_order', 'custom_email_recipient_new_order', 10, 2 );
  2. function custom_email_recipient_new_order( $recipient, $order ) {
  3. // Get the shipping country
  4. $country_code = $order->get_shipping_country();
  5.  
  6. // Get All Zone IDs
  7. $zone_ids = array_keys( array('') + WC_Shipping_Zones::get_zones() );
  8.  
  9. // Loop through Zone IDs
  10. foreach ( $zone_ids as $zone_id ) {
  11. // Get the shipping Zone object
  12. $shipping_zone = new WC_Shipping_Zone($zone_id);
  13.  
  14. // Loop through Zone locations
  15. foreach ( $shipping_zone->get_zone_locations() as $location ){
  16. if ( $location->type === 'country' && $location->code === $country_code ) {
  17. $the_zone_id = $zone_id;
  18. $the_zone_name = $shipping_zone->get_zone_name(); // (You can use the the zone name too)
  19. break;
  20. }
  21. }
  22. if($found) break;
  23. }
  24.  
  25. if( $the_zone_id == 0 ) {
  26. $recipient .= ',' . 'james.collins@gmail.com';
  27. } elseif( $the_zone_id == 2 ) {
  28. $recipient .= ',' . 'jean.dubreuil@gmail.com';
  29. } elseif( $the_zone_id == 3 ) {
  30. $recipient .= ',' . 'joel.chalamousse@gmail.com';
  31. } else {
  32. $recipient .= ',' . 'isabelle.frottin@gmail.com';
  33. }
  34.  
  35. return $recipient;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement