WooCommerce send new order email to customer

后端 未结 3 1469
野性不改
野性不改 2020-12-18 16:52

I have a problem and it sounds stupid, but I\'m really stucked.

I need to send \"new order\" email also to customer. I tried adding function to functions.php file,

3条回答
  •  我在风中等你
    2020-12-18 17:14

    You do not need to do all these stuff again for sending multiple emails. You can simply add recipient to "New Order" email(with customer's email). Here is the code you can try:

    get_items();
    
        // check if a shipped product is in the order   
        foreach ( $items as $item ) {
            $product = $order->get_product_from_item( $item );
    
            // add our extra recipient if there's a shipped product - commas needed!
            // we can bail if we've found one, no need to add the recipient more than once
            if ( $product && $product->needs_shipping() ) {
                $recipient .= ', warehouse-manager@example.com';
                return $recipient;
            }
        }
    
        return $recipient;
    }
    add_filter( 'woocommerce_email_recipient_new_order', 'sv_conditional_email_recipient', 10, 2 );
    

提交回复
热议问题