Search code examples
phpwordpresswoocommerceordersemail-templates

Add order number to a string in WooCommerce email body template


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>


Solution

  • 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>