Fatal error: $order null in view-order template include
-
Hi,
Found a fatal error after update to 4.3.3. Caused by templates/myaccount/view-order.php loading its sub-template via a plain include(). WooCommerce passes $order and $order_id as wc_get_template() args, but those don’t survive into the include scope, so $order is null when view-order/02.php tries to use it.
Fixed by replacing the bare include() at the bottom of view-order.php with:
if ( empty( $order ) ) { global $wp; if ( empty( $order_id ) ) { $order_id = absint( get_query_var( 'view-order' ) ); if ( ! $order_id && isset( $wp->query_vars['view-order'] ) ) { $order_id = absint( $wp->query_vars['view-order'] ); } } if ( $order_id ) { $order = wc_get_order( $order_id ); } } if ( ! empty( $order ) ) { include( $view_order_template ); }Thanks
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.