Display only completed orders on my accounts page

I have a woocommerce shopping site that is going live shortly with just one item left!

In the account area you can click ‘orders’ and see your order i.e. completed, cancelled, on hold etc etc.

However when you click ‘collection’ (a page I have made within the account area) I want it to display only ‘completed’ items.

I have tried to put the following code into the functions.php but with no luck:

(ref - https://businessbloomer.com/woocommerce-display-products-purchased-user/)

add_shortcode( 'my_products', 'bbloomer_user_products_bought' );
 
function bbloomer_user_products_bought() {
global $product, $woocommerce, $woocommerce_loop;
$columns = 3;
$current_user = wp_get_current_user();
$args = array(
    'post_type'             => 'product',
    'post_status'           => 'publish',
    'meta_query'            => array(
        array(
            'key'           => '_visibility',
            'value'         => array('catalog', 'visible'),
            'compare'       => 'IN'
        )
    )
);
$loop = new WP_Query($args);
 
ob_start();
 
woocommerce_product_loop_start();
 
while ( $loop->have_posts() ) : $loop->the_post();
$theid = get_the_ID();
if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $theid ) ) {
wc_get_template_part( 'content', 'product' ); 
} 
endwhile; 
 
woocommerce_product_loop_end();
 
woocommerce_reset_loop();
wp_reset_postdata();
 
return '<div class="woocommerce columns-' . $columns . '">' . ob_get_clean() . '</div>';
}

and then adding the shortcode:

[my_products]

when you click the collection link it does not display anything - well generates a div with nothing in it!

Is there a better way of doing this or a alternative?

I have the latest X and Woo. When you log in you will already have a ‘completed’ item. On the site click in the top menu ‘sign in’ and then the option ‘collections’

Any help would be amazing thank you!

Hi,

Thanks for writing in! Regretfully, this particular customization request is outside the scope of our support as this is not related to an issue with the theme and instead has to do with woocommerce customization. As such, you will need to investigate this particular issue on your own or seek help from a developer should you not feel comfortable making these changes yourself. We do have an in-house custom development team that offer paid services, who may be able to assist. They can be contacted at [email protected] if this is of interest to you. If you have any further questions about the theme, we are more than happy to provide you with assistance on these inquiries.

Thank you for your understanding.

Thank you for the update on this

You’re welcome.