Woocommerce Emails sending Post ID insead of order number
-
Hello, I’m having an issue with switching to HPOS in woocommerce.
I’ve read that you need to use this code to retrieve the order number properly:
“Instead of referencing $order->id or $order->get_id() when fetching order data, use $order->get_order_number()”
The issue im having, is the woocommerce admin order page, AND the PDF packing slips i generate with a third party plugin, display the correct order number.
However, the emails generated by woocommerce, are showing the post id instead of the order number.
I’ve looked into the emails template, and in the “email-order-details.php” file, it appears to be where it sources the order number. The section of that template where it sources the order number is:“/* translators: %1$s: Order ID. %2$s: Order date */ echo wp_kses_post( wc_strtoupper( sprintf( esc_html__( ‘[Order #%1$s] (%2$s)’, ‘woocommerce’ ), $order->get_order_number(), wc_format_datetime( $order->get_date_created() ) ) ) ) . “\n”; echo “\n” . wc_get_email_order_items( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped “
Which appears to use the correct “$order->get_order_number()” function. however, it displays the post ID in emails, not the custom order number that is displayed in the admin order page.
Additionally…..the email settings use a variable of {order_number} which retrieves the order number in an unknown way.
When using the legacy storage, all works fine, but when using HPOS, it doesn’t work properly with woocommerce emails.
Any insight?
- The topic ‘Woocommerce Emails sending Post ID insead of order number’ is closed to new replies.