Brian Francoeur
Brian Francoeur

Reputation: 85

WooCommerce Storefront theme: How to show order details on order-received endpoint?

After the last WooCommerce update, the order details no longer displayed on the Thank You page. Since then, I have developed a child theme using the WooCommerce Storefront theme. No matter what I have tried, All I see is the 'thank you' message on the thank you page.

What I have tried so far:

Am I missing something here, or is there something going on with WooCommerce? Any help would be greatly appreciated:)

UPDATE: Found that I have two versions of jQuery running: v1.11.3, and v1.12.4. There are also two different versions of jQueryUI loading: v1.10.4, and v1.11.4. Currently disabling WordPress plugins and noting what jquery versions are loading in the browser.

UPDATE: Found one plugin using jQueryUI v1.10.4. Still looking for the others.

UPDATE: Finished toubleshooting all the plugins, except WooCommerce (WSOD). MailChimp MailMunch plugin was making the google api call to the older jquery version (v1.11.3), while the Spider Player was calling the older version of jQueryUI. De-activated both plugins, and STILL the same result. It's as if WooCommerce is simply ignoring the order details in the middle of the thankyou.php template.

Any thoughts or ideas? I am really at a loss now. I can fix the jquery issues in the disabled plugins, but that won't fix my pressing issue with the Thank You page.

Any help would be greatly appreciated:)

UPDATE: After a lot more work, I have determined that WooCommerce IS using the child theme thankyou.php. Further troubleshooting also revealed that $order is false. This is why I am not seeing order details on the thank you page. Next: Figure why $order is false (It is an instance of WC_Order).

UPDATE: I did a stacktrace:

#0 /home/onyour6test/www/wp-content/plugins/woocommerce/includes/wc-core-functions.php(203): include() 

#1 /home/onyour6test/www/wp-content/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-checkout.php(212): wc_get_template('checkout/thanky...', Array) 

#2 /home/onyour6test/www/wp-content/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-checkout.php(59): WC_Shortcode_Checkout::order_received(NULL) 

#3 /home/onyour6test/www/wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php(71): WC_Shortcode_Checkout::output('') 

#4 /home/onyour6test/www/wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php(138): WC_Shortcodes::shortcode_wrapper(Array, '') 

#5 /home/onyour6test/www/wp-includes/shortcodes.php(326): WC_Shortcodes::checkout('', '', 'woocommerce_che...') 

#6 [internal function]: do_shortcode_tag(Arr in /home/onyour6test/www/wp-content/themes/storefront-child/woocommerce/checkout/thankyou.php on line 77

I think the culprit may be in stacktrace #2: ...WC_Shortcode_Checkout::order_received(NULL).

Stacktrace #6 seems to confirm this, with do_shortcode_tag. Line 77 refers to where the call to $order fails, specifically here:

<strong><? php _e( 'Order Number:', 'woocommerce' ); ?></strong>

I managed to get this particular line of code to display, but it showed only "Order" in "Order Number", followed by a 500 internal server error. None of the rest of the remaining HTML or order-detail variables rendered on the page.

UPDATE: This appears to be something with the WooCommerce code itself. $order_id is empty, causing $order to return NULL. This prevents the order details from being displayed. This should display by default, with an option to turn it off in WooCommerce settings.

Upvotes: 0

Views: 3728

Answers (1)

gregdev
gregdev

Reputation: 1943

The problem is $show_customer_details in order/order-details.php is set to false if the customer is not logged in.

I modified the customer check in my theme copy of order-details.php to also check if the order key (post password) matches the key that's provided as a URL parameter. This is the same check that WooCommerce performs when working out if it's okay to show the order info on the thank you page:

$order_key             = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET['key'] ) ? '' : wc_clean( $_GET['key'] ) );
$show_customer_details = $order_key == $order->get_order_key() || (is_user_logged_in() && $order->get_user_id() === get_current_user_id());

It's not pretty but it works.

Upvotes: 0

Related Questions