'publish',
'limit' => 24,
'orderby' => 'popularity',
'order' => 'DESC',
);
$products = wc_get_products($args);
$data = array();
foreach($products as $product) {
$imgs = $product->get_gallery_image_ids();
$mainId = $product->get_image_id();
$imgSrc = $mainId ? wp_get_attachment_image_url($mainId, 'woocommerce_thumbnail') : wc_placeholder_img_src();
$price = $product->get_price();
$regP = $product->get_regular_price();
$saleP = $product->get_sale_price();
$data[] = array(
'id' => $product->get_id(),
'name' => $product->get_name(),
'link' => get_permalink($product->get_id()),
'img' => $imgSrc,
'price' => $price,
'regular' => $regP ?: $price,
'sale' => $saleP,
'on_sale' => $product->is_on_sale(),
'rating' => $product->get_average_rating(),
'new' => (strtotime($product->get_date_created()) > strtotime('-60 days')),
);
}
echo '';
endif;
?>