• Resolved okap1

    (@okap1)


    I’m trying to intercept the event that sends the tracking email to the customer because I would like to also send the tracking to the sales rep linked to the customer, how can I do that?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support villasupport

    (@villasupport)

    Hi,

    Please disable sending tracking email for an order (https://prnt.sc/tLC3QfCTtrmm), this will be applied for all other orders, the tracking email will not be sent since you disable it.

    Best regards.

    Plugin Support lavendervu2510

    (@lavendervu2510)

    Hi,

    Please disable sending tracking email for an order (https://prnt.sc/tLC3QfCTtrmm), this will be applied for all other orders, the tracking email will not be sent since you disable it.

    Best regards.

    Thread Starter okap1

    (@okap1)

    I’m using your plugin to send tracking number with email to customers, It’s ok but I need to send a copy of the same email to a sales manager responsible. I’ve done the same thing for the WooCommerce order confirmation email. Here’s the script I’ve created. I want to do the same when sending the tracking email to the customer. It should also be sent to the sales manager.

    Example:

    //START send each customer email also to the agent
    function send_email_to_agent( $recipient, $order ) {

    // Bail on WC settings pages since the order object isn't yet set yet
    $page = $_GET['page'] = isset( $_GET['page'] ) ? $_GET['page'] : '';
    if ( 'wc-settings' === $page ) {
        return $recipient;
    }
    
    // just in case
    if ( ! $order instanceof WC_Order ) {
        return $recipient;
    }
    
    // if the customer of this order, or his group has an assigned agent
    $customer_id = $order->get_customer_id();
    
    // first, check if the customer has an agent assigned directly.
    $customer_agent = get_user_meta($customer_id,'salesking_assigned_agent', true);
    if (!empty($customer_agent) && $customer_agent !== 'none'){
        // found agent
    } else {
        // keep searching in the group
        $customer_is_b2b = get_user_meta($customer_id,'b2bking_b2buser', true);
        if ($customer_is_b2b === 'yes'){
            $customergroup = get_user_meta($customer_id, 'b2bking_customergroup', true);
            $customer_agent = get_post_meta($customergroup, 'salesking_assigned_agent', true);
        }
    }
    
    if (empty($customer_agent) or $customer_agent === 'none'){
        $order_id = $order->get_id();
        $customer_agent = $order->get_meta('salesking_assigned_agent');
    }
    
    if (!empty($customer_agent) && $customer_agent !== 'none'){
        // send email to agent as well
        $agent_info = get_userdata($customer_agent);
        $agent_email = $agent_info->user_email;
        $recipient .= ', '.$agent_email;
    }
    
    return $recipient;

    }

    add_filter( ‘woocommerce_email_recipient_customer_completed_order’, ‘send_email_to_agent’, 10, 2 );

    I need to do something similar with the tracking number

    Thread Starter okap1

    (@okap1)

    if I edit in the “import_csv.php” like this way it works, but can I override it in my child theme? If not, how can I do the same?

       public static function send_mail( $order_id, $imported = array(), $update_scheduled_emails = false ) {
    ...
    ...
    
    
    $order = wc_get_order( $order_id );
    
    if ( $order instanceof WC_Order ) {
    $customer_id = $order->get_customer_id();
    $customer_agent = get_user_meta( $customer_id, 'salesking_assigned_agent', true );
    
    if ( ! empty( $customer_agent ) && $customer_agent !== 'none' ) {
    $agent_info = get_userdata( $customer_agent );
    $agent_email = $agent_info->user_email;
    
    }
    }
    
    $headers = apply_filters( 'woo_orders_tracking_email_headers', "Content-Type: text/html\r\nReply-to: {$email->get_from_name()} <{$email->get_from_address()}>\r\n", $email );
    $headers .= 'Cc:' . $agent_email . "\r\n";
    
    add_filter( 'woocommerce_email_styles', array( __CLASS__, 'woocommerce_email_styles' ) );
    $send = $email->send( $user_email, $subject, $content, $headers, array() );
    remove_filter( 'woocommerce_email_styles', array( __CLASS__, 'woocommerce_email_styles' ) );
    if ( $update_scheduled_emails && false !== $send ) {
    /*Remove from scheduled orders if any*/
    $orders = get_option( 'vi_wot_send_mails_for_import_csv_function_orders' );
    if ( $orders ) {
    $orders = vi_wot_json_decode( $orders );
    if ( count( $orders ) ) {
    $orders = array_diff( $orders, array( $order_id ) );
    update_option( 'vi_wot_send_mails_for_import_csv_function_orders', vi_wot_json_encode( $orders ) );
    }
    }
    }

    Plugin Support lavendervu2510

    (@lavendervu2510)

    Hi,

    Unfortunately, we do not provide support if you have implemented custom code in the plugin.

    Best regards.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Sending tracking number email to sales rep’ is closed to new replies.