Displaying a coupon message on emails for completed order status only

后端 未结 1 775
夕颜
夕颜 2021-01-07 12:01

I\'ve got that code that displays a coupon message in the email orders if the customer has not used any in this order.

I would like to display that coupon message on

相关标签:
1条回答
  • 2021-01-07 12:31

    It is possible easily to display a custom message on emails with an if statement and 2 conditions, for "complete" order status only.

    add_action( 'woocommerce_email_before_order_table', 'completed_order_mail_message', 20 );
    function completed_order_mail_message( $order ) {
        if ( empty( $order->get_used_coupons() ) && $order->post_status == 'wc-completed' )
            echo '<h2 id="h2thanks">Get 20% off</h2><p id="pthanks">Thank you for making this purchase! Come back and use the code "<strong>Back4More</strong>" to receive a 20% discount on your next purchase! Click here to continue shopping.</p>';
    }
    

    This code goes on function.php file of your active child theme or theme

    This code is tested and works perfect

    BUT to autocomplete paid orders you need to add something:
    WooCommerce: Auto complete paid Orders (depending on Payment methods)

    Reference:

    • Add coupon to the processing order email only if the customer have not used one
    • WooCommerce: Auto complete paid Orders (depending on Payment methods)
    0 讨论(0)
提交回复
热议问题