درود.
شورتکدی که توسط ووکامرس معرفی شده این هست :
[woocommerce_my_account order_count="-1"]
اگر هم با شورتکد قبلی نتیجه نگرفتید، کد زیر رو در فایل functions.php قالبتون قرار بدید:
add_shortcode( 'my_products', 'masih_user_products_bought' );
function masih_user_products_bought() {
global $product, $woocommerce, $woocommerce_loop;
$columns = 3;
$current_user = wp_get_current_user();
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => -1
);
$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>';
}
و در نهایت شورتکد زیر رو در یک برگه قرار بدید:
[my_products]