• Hi there. Thanks for the simple but great plugin!

    I have a function set to add an additional mail recipient to woocommerce_email_headers allowing new orders notifications to be sent to the additional email address. I’ve made it to work in such a way that if the user selects a specific city on checkout page, then the function is triggered.

    I’d like to use the same logic so that the whatsapp phone number is changed when the user picks a specific city. Could anyone help to inspect the plugin’s functions and adjust the function bellow to work with it?

    Thanks in advance.

    <?php
    function my_function_add_recipient( $recipient, $order ) {
    global $woocommerce;
    
    $additional_recipient = '[email protected]';
    
    $customer_city = array('New York'); // an array of values to be matched - this will check for the $field['billing_city'] within the $order variable
    if ( in_array( $order->billing_city, $customer_city ) ) {
    // Add additional email to the recipient list
    $recipient = $recipient . ', ' . $additional_recipient;
    }
    return $recipient;
    }
    add_filter( 'woocommerce_email_recipient_new_order', 'my_function_add_recipient', 10, 2 );
    
    // Ensures mail header is properly set so emails are not sent to spam folder
    add_filter( 'woocommerce_email_headers', 'add_bcc_to_wc_admin_new_order', 10, 3 );
    function add_bcc_to_wc_admin_new_order( $headers = '', $id = '', $wc_email = array() ) {
        if ( $id == 'new_order' ) {
            $headers .= "Bcc: [email protected]\r\n";
        }
        return $headers;
    }
    ?>

    https://www.ads-software.com/plugins/whatsapp-woocommerce-integration/

  • The topic ‘Send Message to different phone number if a field on checkout page is selected?’ is closed to new replies.