skip to Main Content

I’m trying to change the on-hold email to include the order number in the introduction.

I’ve added "$order->get_id()" to show the order number. Not quite working. Any ideas?

<p><?php esc_html_e( 'Thanks for your order. Your order number is $order->get_id(). Below you can find the contents of your order.', 'woocommerce' ); ?></p>

2

Answers


  1. This is because it is now seen as part of the string, it’s missing the concatenation operator ('.')

    More info: String Operators

    Use it like this instead

    <p><?php esc_html_e( 'Thanks for your order. Your order number is ' . $order->get_id() . ' Below you can find the contents of your order.', 'woocommerce' ); ?></p>
    

    Example:

    Not

    'First part of string $myvar Second part of string';
    

    But

    'First part of string' . $myvar . 'Second part of string';
    


    EDIT

    Another option: see Loic’s answer,
    double answer, posted simultaneously

    Login or Signup to reply.
  2. You need to concatenate the order number in the string… You can use, in a better way, printf() and the WC_Order method get_order_number() as follows:

    <p><?php printf( esc_html__( 'Thanks for your order. Your order number is %s. Below you can find the contents of your order.', 'woocommerce' ), $order->get_order_number() ); ?></p>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search