Skip to content
Advertisement

Why does WooCommerce Order Shortcode Generate Plugin Notice on Custom Thank You Page?

I have created a re-direct to a custom “Thank You” (order-received) page in WooCommerce by using my child theme and functions.php.

The re-direct works as intended and all other shortcodes that I have created works fine, except for this.

When inserting my [order_cost_breakdown] shortcode using Gutenberg on my Thanks page and when placing on order, I get this notice:

JavaScript

I am not sure what I need to edit in that template to make this work or what I need to change in my shortcode function to make this work.

This is the shortcode function:

JavaScript

If someone can help me understand and / or fix this, that would be really helpful.

Advertisement

Answer

As it can be seen in the source code of woocommerce: https://github.com/woocommerce/woocommerce/blob/00e38b51ef9276f0063d9df7796f19b92ca3ff76/templates/order/order-details.php, there is this order level $show_purchase_note, which is transmitted to every item view in the forecast loop. This controls whether product level purchase notes (if any) should be displayed or not. You should do the same:

Figure out its value:

JavaScript

And send it to every item view in the loop, together with the value of the product’s purchase note (note the last two template arguments):

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement