• Resolved admirvirtua

    (@admirvirtua)


    Hello,

    I have a quick question, if anyone else had to implement something similar. A client has some weird implementation of ERP system, so we have to do many non standard things. But I was wondering if there is a simple way of sending different mails at the order status completed, depending on shipping type.

    Example, if the customer chooses shipping to their address it would say, something like, your order xxxx was sent to your address.
    But if they choose personal pickup, it would say something like the order xxxx was sent to this and this shop. When it arrives we will contact you via text message.

    It’s a crude example, but I think it gets the point across.

    Thank you in advanced.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Missy a11n

    (@m155y5)

    Automattic Happiness Engineer

    Hi @admirvirtua

    You might look at AutomateWoo for this. It offers a workflow rule that can send a specific email depending on Shipping method or keywords in the shipping method.

    Thread Starter admirvirtua

    (@admirvirtua)

    Thank you for the reply, in the end we added some custom functionality into the themes functions.php. If someone else wants to do it this way, here is the code snippet.

    
    add_action( 'woocommerce_email_before_order_table', 'add_order_email_instructions', 10, 2 );
    
    function add_order_email_instructions( $order, $sent_to_admin ) {
    
    	$shipping_method = @array_shift( $order->get_shipping_methods() );
    	$shipping_method_id = $shipping_method['method_id'];
    	$status = $order->get_status();
    
    	if ( ! $sent_to_admin && $status === 'completed' ) {
    		if ( 'local_pickup' == $shipping_method_id ) {
    			// local pickup option
    			echo '<p>Foo</p>';
    		} else {
    			// other methods
    			echo '<p>Bar</p>';
    		}
    	}
    }

    This just adds the part to the email we wanted. So the main formatting is still done in the WooCommerce settings.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Different mail on completed order status’ is closed to new replies.