I am trying to get product data from Woocommerce on my Wordpress website. I used the code below to get the name and thumbnail images of products of a particular category.
<?php
$args = array( 'post_type' => 'product', 'posts_per_page' => 10, 'product_cat' => 'Tools' );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
global $product;
echo '<br /><a href="'.get_permalink().'">' . woocommerce_get_product_thumbnail().' '.the_title().'</a>';
endwhile;
wp_reset_query();
?>
This works fine in getting the Name and Image of products in the category "Tools", but I want to get the weight for each product.
The product Weight is set as a product attribute in the Wordpress Dashboard.
How do I get this data for products? I can't seem to find the functions to access these.