Search
Change my orders template if order from other shops are not visible - WP Global Cart
14231
documentation-template-default,single,single-documentation,postid-14231,theme-awake,eltd-core-1.1,woocommerce-no-js,awake child-child-ver-1.0.0,awake-ver-1.0,eltd-smooth-scroll,eltd-smooth-page-transitions,eltd-mimic-ajax,eltd-grid-1200,eltd-blog-installed,eltd-default-style,eltd-fade-push-text-top,eltd-header-standard,eltd-sticky-header-on-scroll-down-up,eltd-default-mobile-header,eltd-sticky-up-mobile-header,eltd-menu-item-first-level-bg-color,eltd-dropdown-slide-from-top,eltd-,eltd-fullscreen-search eltd-search-fade,eltd-side-menu-slide-from-right,wpb-js-composer js-comp-ver-6.3.0,vc_responsive
 

Change my orders template if order from other shops are not visible

WP Global Cart / Change my orders template if order from other shops are not visible
Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on TumblrPin on PinterestEmail this to someonePrint this page

Change my orders template if order from other shops are not visible

As default the orders of a customer should be available and visible on front side, within My Account at Orders section. It happens for certain orders to be ignored since the theme is not aware of orders being available across whole network. The default template file is located at woocommerce/myaccount/orders.php within your theme. If the file does not exist we recommend to copy over from woocommerce plugin.

The template file contain the following:

			foreach ( $customer_orders->orders as $customer_order ) {
				$order      = wc_get_order( $customer_order ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
				$item_count = $order->get_item_count() - $order->get_item_count_refunded();
				?>
				<tr class="woocommerce-orders-table__row woocommerce-orders-table__row--status-<?php echo esc_attr( $order->get_status() ); ?> order">
					<?php foreach ( wc_get_account_orders_columns() as $column_id => $column_name ) : ?>

                                ... more code ...
	
					<?php endforeach; ?>
				</tr>
				<?php
			}

This need a bit of update to include the switch_to_blog() and restore_current_blog() so add the 2 new lines:

            foreach ( $customer_orders->orders as $customer_order ) {
                
                if ( isset ( $customer_order->blog_id ) ) switch_to_blog($customer_order->blog_id);
                
                $order      = wc_get_order( $customer_order ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
                $item_count = $order->get_item_count() - $order->get_item_count_refunded();
                ?>
                <tr class="woocommerce-orders-table__row woocommerce-orders-table__row--status-<?php echo esc_attr( $order->get_status() ); ?> order">
                    <?php foreach ( wc_get_account_orders_columns() as $column_id => $column_name ) : ?>

                                ... more code ...
    
                    <?php endforeach; ?>
                </tr>
                <?php
                
                if ( isset ( $customer_order->blog_id ) ) restore_current_blog();
            }

At his point, All orders from any shops will be included everywhere in-network at My Account > Orders section.

0
Would love your thoughts, please comment.x
()
x