okap1
Forum Replies Created
-
Forum: Plugins
In reply to: [Orders Tracking for WooCommerce] Sending tracking number email to sales repif 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 ) ); } } }
Forum: Plugins
In reply to: [Orders Tracking for WooCommerce] Sending tracking number email to sales repI’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