Woocommerce get products

Posted by LaravelIndia - 3 months ago

Get the list of product categories form WooCommerce in WordPress

$args = array(
    'post_type'      => 'product',
    'posts_per_page' => 10
);

$get_all_products = new WP_Query( $args );

while ( $get_all_products->have_posts() ) : $get_all_products->the_post();
    global $product;
    echo '<br /><a href="'.get_permalink().'">' . woocommerce_get_product_thumbnail().' '.get_the_title().'</a>';
endwhile;

wp_reset_query();

using wc_get_products

$args = array(
    'orderby'  => 'name',
);
$products = wc_get_products( $args );

WooCommerce documentation