• Resolved mikejandreau

    (@mikejandreau)


    I’m trying to do something I think should be simple, but isn’t working.

    In my completed-order email template, I’m using:

    <?php if ( $order->has_status( 'wc-hand' ) ) { ?>
    DO MY STUFF HERE

    I verified in my wp_wc_order_stats table that the order has the status I want.

    But DO MY STUFF HERE isn’t showing up in my email.

    If I use a stock status, such as:

    <?php if ( $order->has_status( 'pending' ) ) { ?>
    DO STUFF

    It works.

    I don’t know why it’s ignoring my custom statuses, but it is.

    Pointers? Thoughts? Am I going about this all wrong?

    All I ultimately want to do is change the text in my completed order email if an order is hand delivered versus shipped.

    • This topic was modified 4 years, 10 months ago by mikejandreau.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter mikejandreau

    (@mikejandreau)

    I gave up on this and reversed my logic. Since the email template only fires when an order is Completed, I set up the IF ELSE in the opposite order.

    <?php if ( $order->has_status( 'completed' ) ) { ?>
    COMPLETED TEXT

    Then a simple elseif since my custom status is sending the same template but wouldn’t be “completed” (but instead would be my custom status).

    Plugin Support kellymetal a11n

    (@kellymetal)

    Hi there,

    I’m glad to hear you were able to sort this out by changing up your IF/ELSE logic here.

    I had tried adding your original snippet to my completed order email and it worked when I had has_status( 'completed' ), then tried creating a custom status with our WooCommerce Order Status Manager extension… then realized changing the order to the custom wc-hand status would not trigger the Order Completed email, and setting it to Completed to trigger the email would mean the has_status('wc-hand') would never be true (since it’s completed). Soooo that makes sense that it would not work!

    Anyway, thank you for sharing your workaround here — hopefully it helps others in the community.

    I’m going to mark this thread as resolved. If you have any further questions, please start a new thread.

    Have a wonderful day!

    Thread Starter mikejandreau

    (@mikejandreau)

    Hi Kelly,

    Yes, the wc-hand would not have sent the Completed order email, normally.

    However, I wrote a custom function to send that email when an order status changed to my Hand Delivered custom status.

    But the if/else doesn’t work with the custom status (it looks like a bug in the logic), so I worked around that.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Using Custom Status in Email Template’ is closed to new replies.