Good morning and thank you for the reply, that makes sense what you said but it did not seem to work.
In the functions page here is what I have put together to create the collections page:
Created the shortcode to show completed orders
function shortcode_my_orders( $atts ) {
extract( shortcode_atts( array(
'order_count' => -1
), $atts ) );
ob_start();
wc_get_template( 'myaccount/my-orders.php', array(
'current_user' => get_user_by( 'id', get_current_user_id() ),
'order_count' => $order_count
) );
return ob_get_clean();
}
add_shortcode('my_orders', 'shortcode_my_orders');
Filter to completed:
add_filter( 'woocommerce_my_account_my_orders_query', 'custom_my_orders_query' );
function custom_my_orders_query($args){
$args['post_status'] = array('wc-completed');
return $args;
}
Created the custom page:
// 1. Register new endpoint to use for My Account page
// Note: Resave Permalinks or it will give 404 error
function bbloomer_add_collection_endpoint() {
add_rewrite_endpoint( 'collection', EP_ROOT | EP_PAGES );
}
add_action( 'init', 'bbloomer_add_collection_endpoint' );
// ------------------
// 2. Add new query var
function bbloomer_collection_query_vars( $vars ) {
$vars[] = 'collection';
return $vars;
}
add_filter( 'query_vars', 'bbloomer_collection_query_vars', 0 );
// ------------------
// 3. Insert the new endpoint into the My Account menu
function bbloomer_add_collection_link_my_account( $items ) {
$items['collection'] = 'Collection';
return $items;
}
add_filter( 'woocommerce_account_menu_items', 'bbloomer_add_collection_link_my_account' );
// ------------------
// 4. Add content to the new endpoint
function bbloomer_collection_content() {
//echo '<h3>Premium WooCommerce Support</h3></p>';
echo do_shortcode( '[my_orders]' );
}
Added to the menus on my account page:
add_action( 'woocommerce_account_collection_endpoint', 'bbloomer_collection_content' );
function wpb_woo_my_account_order() {
$myorder = array(
'dashboard' => __( 'Dashboard', 'woocommerce' ),
'wishlist' => __( 'Wishlist', 'woocommerce' ),
'orders' => __( 'Orders', 'woocommerce' ),
'collection' => __( 'Collection', 'woocommerce' ),
'edit-address' => __( 'Address', 'woocommerce' ),
'edit-account' => __( 'Password', 'woocommerce' ),
'customer-logout' => __( 'Logout', 'woocommerce' ),
);
return $myorder;
}
add_filter ( 'woocommerce_account_menu_items', 'wpb_woo_my_account_order' );
So the orders page should just be all orders (completed, pending, hold etc) where the collection should just be completed.
I will add your details now thank you!