Skip to content
Advertisement

Call to a member function get_items() on boolean in WooCommerce thankyou

I am trying to get order details to display a summary on my thank you page. The issue I am having is that this code snippet I have is breaking my wordpress. I have the stacktrace but I am unsure on how to fix it. The code to me looks correct so ensure why it’s not working. Does anybody have any idea what is the meaning of this stacktrace and how I can fix it?

JavaScript

My code:

JavaScript

UPDATE Adding the shortcode

enter image description here

Advertisement

Answer

The variable $order_id is not defined, $item->get_quantity need to be $item->get_quantity() and the output should never be echoed with a shortcode, always returned.

This shortcode is to be used on Order received page

JavaScript

Code goes in functions.php file of the active child theme (or active theme). Tested and works.

USAGE:

  • [order_table_summary]
  • or also inside PHP code: echo do_shortcode('[order_table_summary]');

Just for testing:

JavaScript

Related:

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