title: WooCommerce Storefront theme: How to show order details on order-received endpoint?
body: <p>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. </p>
  
  <p>What I have tried so far:</p>
  
  <ul>
  <li>Troubleshooting the entire process to find anything that might be wrong.
  This included the following:</li>
  <li>Checked for wc template function that calls the order-details template and it related action hook (both exist)</li>
  <li>Making sure my child-theme's WooCommerce directory was correctly structured. Everything else works correctly, including my custom template fragments and their hooks. </li>
  <li>Paying careful attention to syntax errors, including those that might silently fail. </li>
  <li>Copied the WooCommerce directory from the plugin into the child theme. This yielded the same exact result--no order details on thank you page.</li>
  <li>Eliminated WordPress Thank You page and used the default WooCommerce endpoint ('order-received'). NOTE: Due to the way this affected layout and display, I reverted back to my original WooCommerce directory structure, which is identical to the WooCommerce template directory, minus some of the sub-directories. (UPDATE: I actually am still using the copied WooCommerce directory)</li>
  <li>Wrote a custom function with action hook in child theme's functions.php file, with no change in output.</li>
  <li>In thankyou.php, created an action hook and wrote a function that used wc_get_template to call order-details, but it didn't work (silent fail)</li>
  <li><p>Updated WordPress from 4.5 to 4.6.1, Updated the Storefront theme, and updated any outdated WooCommerce template files in my child theme.</p>
  
  <pre><code>Code:
  **storefront-child/woocommerce/wc-template-functions.php**
  
  if ( ! function_exists( 'woocommerce_order_details_table' ) ) {
  
      /**
       * Displays order details in a table.
       *
       * @param mixed $order_id
       * @subpackage  Orders
       */
      function woocommerce_order_details_table( $order_id ) {
          if ( ! $order_id ) return;
  
          wc_get_template( 'order/order-details.php', array(
              'order_id' =&gt; $order_id
          ) );
      }
  }
  
  
  
  **storefront-child/woocommerce/wc-template-hooks.php
  
  /**
   * Order details.
   *
   * @see woocommerce_order_details_table()
   * @see woocommerce_order_again_button()
   */
   add_action( 'woocommerce_view_order', 'woocommerce_order_details_table', 10 );
   add_action( 'woocommerce_thankyou', 'woocommerce_order_details_table', 10 );
   add_action( 'woocommerce_order_details_after_order_table', 'woocommerce_order_again_button' );
  
  
  
  **storefront-child/woocommerce/checkout/thankyou.php**
  
  if ( ! defined( 'ABSPATH' ) ) {
      exit;
  }
  
  if ( $order ) : ?&gt;
  
      &lt;?php if ( $order-&gt;has_status( 'failed' ) ) : ?&gt;
  
      &lt;p class="woocommerce-thankyou-order-failed"&gt;&lt;?php _e( 'Unfortunately your order cannot be processed as the originating bank/merchant has declined your transaction. Please attempt your purchase again.', 'woocommerce' ); ?&gt;&lt;/p&gt;
  
      &lt;p class="woocommerce-thankyou-order-failed-actions"&gt;
          &lt;a href="&lt;?php echo esc_url( $order-&gt;get_checkout_payment_url() ); ?&gt;" class="button pay"&gt;&lt;?php _e( 'Pay', 'woocommerce' ) ?&gt;&lt;/a&gt;
          &lt;?php if ( is_user_logged_in() ) : ?&gt;
              &lt;a href="&lt;?php echo esc_url( wc_get_page_permalink( 'myaccount' ) ); ?&gt;" class="button pay"&gt;&lt;?php _e( 'My Account', 'woocommerce' ); ?&gt;&lt;/a&gt;
          &lt;?php endif; ?&gt;
      &lt;/p&gt;
  
  &lt;?php else : ?&gt;
  
      &lt;p class="woocommerce-thankyou-order-received"&gt;&lt;?php echo apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Thank you. Your order has been received.', 'woocommerce' ), $order ); ?&gt;&lt;/p&gt;
  
      &lt;ul class="woocommerce-thankyou-order-details order_details"&gt;
          &lt;li class="order"&gt;
              &lt;?php _e( 'Order Number:', 'woocommerce' ); ?&gt;
              &lt;strong&gt;&lt;?php echo $order-&gt;get_order_number(); ?&gt;&lt;/strong&gt;
          &lt;/li&gt;
          &lt;li class="date"&gt;
              &lt;?php _e( 'Date:', 'woocommerce' ); ?&gt;
              &lt;strong&gt;&lt;?php echo date_i18n( get_option( 'date_format' ), strtotime( $order-&gt;order_date ) ); ?&gt;&lt;/strong&gt;
          &lt;/li&gt;
          &lt;li class="total"&gt;
              &lt;?php _e( 'Total:', 'woocommerce' ); ?&gt;
              &lt;strong&gt;&lt;?php echo $order-&gt;get_formatted_order_total(); ?&gt;&lt;/strong&gt;
          &lt;/li&gt;
          &lt;?php if ( $order-&gt;payment_method_title ) : ?&gt;
          &lt;li class="method"&gt;
              &lt;?php _e( 'Payment Method:', 'woocommerce' ); ?&gt;
              &lt;strong&gt;&lt;?php echo $order-&gt;payment_method_title; ?&gt;&lt;/strong&gt;
          &lt;/li&gt;
          &lt;?php endif; ?&gt;
      &lt;/ul&gt;
      &lt;div class="clear"&gt;&lt;/div&gt;
  
  &lt;?php endif; ?&gt;
  
  &lt;?php do_action( 'woocommerce_thankyou_' . $order-&gt;payment_method, $order-&gt;id ); ?&gt;
  &lt;?php do_action( 'woocommerce_thankyou', $order-&gt;id ); ?&gt;
  </code></pre>
  
  
  
  <pre><code>&lt;p class="woocommerce-thankyou-order-received"&gt;&lt;?php echo apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Thank you. Your order has been received.', 'woocommerce' ), null ); ?&gt;&lt;/p&gt;
  
  &lt;?php endif; 
  
  ?&gt;
  
  
  **storefront-child/woocommerce/order/order-details.php**
  
  if ( ! defined( 'ABSPATH' ) ) {
      exit;
  }
  
  $order = wc_get_order( $order_id );
  
  $show_purchase_note    = $order-&gt;has_status( apply_filters( 'woocommerce_purchase_note_order_statuses', array( 'completed', 'processing' ) ) );
  $show_customer_details = is_user_logged_in() &amp;&amp; $order-&gt;get_user_id() === get_current_user_id();
  ?&gt;
  &lt;h2&gt;&lt;?php _e( 'Order Details', 'woocommerce' ); ?&gt;&lt;/h2&gt;
  &lt;table class="shop_table order_details"&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th class="product-name"&gt;&lt;?php _e( 'Product', 'woocommerce' ); ?&gt;&lt;/th&gt;
              &lt;th class="product-total"&gt;&lt;?php _e( 'Total', 'woocommerce' ); ?&gt;&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
      &lt;?php
          foreach( $order-&gt;get_items() as $item_id =&gt; $item ) {
              $product = apply_filters( 'woocommerce_order_item_product', $order-&gt;get_product_from_item( $item ), $item );
  
              wc_get_template( 'order/order-details-item.php', array(
                  'order'              =&gt; $order,
                  'item_id'            =&gt; $item_id,
                  'item'               =&gt; $item,
                  'show_purchase_note' =&gt; $show_purchase_note,
                  'purchase_note'      =&gt; $product ? get_post_meta( $product-&gt;id, '_purchase_note', true ) : '',
                  'product'            =&gt; $product,
              ) );
          }
      ?&gt;
      &lt;?php do_action( 'woocommerce_order_items_table', $order ); ?&gt;
  &lt;/tbody&gt;
  &lt;tfoot&gt;
      &lt;?php
          foreach ( $order-&gt;get_order_item_totals() as $key =&gt; $total ) {
              ?&gt;
              &lt;tr&gt;
                  &lt;th scope="row"&gt;&lt;?php echo $total['label']; ?&gt;&lt;/th&gt;
                  &lt;td&gt;&lt;?php echo $total['value']; ?&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;?php
          }
      ?&gt;
  &lt;/tfoot&gt;
  </code></pre>
  
  <p></p>
  
  
  
  <pre><code>&lt;?php if ( $show_customer_details ) : ?&gt;
      &lt;?php wc_get_template( 'order/order-details-customer.php',    array( 'order' =&gt;  $order ) ); ?&gt;
  &lt;?php endif; ?&gt;
  
  
  
  **Rendered HTML**
  &lt;div class="entry-content"&gt;
      &lt;div class="mailmunch-forms-before-post" style="display: none !important;"&gt;&lt;/div&gt;
  &lt;div class="woocommerce"&gt;
      &lt;p class="woocommerce-thankyou-order-received"&gt;Thank you. Your order has been received.&lt;/p&gt;    
  &lt;/div&gt;
  
  &lt;!-- This is where the order details should be --&gt;
  
  &lt;p&gt;&amp;nbsp;&lt;/p&gt;
  
  &lt;div class="mailmunch-forms-in-post-middle" style="display: none !important;"&gt;&lt;/div&gt;
  &lt;div class="mailmunch-forms-after-post" style="display: none !important;"&gt;&lt;/div&gt;
  
  &lt;/div&gt;
  </code></pre></li>
  </ul>
  
  <p>Am I missing something here, or is there something going on with WooCommerce? Any help would be greatly appreciated:)</p>
  
  <p>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.</p>
  
  <p>UPDATE: Found one plugin using jQueryUI v1.10.4. Still looking for the others. </p>
  
  <p>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.</p>
  
  <p>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. </p>
  
  <p>Any help would be greatly appreciated:) </p>
  
  <p>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 <strong>false</strong>. 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).</p>
  
  <pre><code>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
  </code></pre>
  
  <p>I think the culprit may be in stacktrace #2: ...WC_Shortcode_Checkout::order_received(NULL).</p>
  
  <p>Stacktrace #6 seems to confirm this, with <strong>do_shortcode_tag</strong>. Line 77 refers to where the call to $order fails, specifically here: </p>
  
  <pre><code>&lt;strong&gt;&lt;? php _e( 'Order Number:', 'woocommerce' ); ?&gt;&lt;/strong&gt;
  </code></pre>
  
  <p>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. </p>
  
  <p>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. </p>