'',
'per_page_mobile' => 1,
'per_page_tablet' => 2,
'per_page_desktop' => 4,
), $atts, 'products_list');
ob_start();
$args = array(
'post_type' => 'product',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => $atts['category'],
),
),
);
$query = new WP_Query($args);
if ($query->have_posts()) {
?>
have_posts()) {
$query->the_post();
global $product;
$product_id = $product->get_id();
$product_image = has_post_thumbnail() ? get_the_post_thumbnail_url($product_id, 'woocommerce_thumbnail') : wc_placeholder_img_src();
$product_title = get_the_title();
$product_price = $product->get_price_html();
$product_link = get_permalink($product_id);
$wishlist_url = function_exists('yith_wcwl_add_to_wishlist_url') ? yith_wcwl_add_to_wishlist_url($product_id) : '#';
$is_in_wishlist = function_exists('yith_wcwl_is_product_in_wishlist') && yith_wcwl_is_product_in_wishlist($product_id);
?>
No products found in this category.';
}
return ob_get_clean();
}
add_shortcode('products_list', 'bfsuma_products_list_shortcode');
// Add inline CSS for styling
function add_bfsuma_product_css() {
?>
get_image('woocommerce_single', '', false);
$title = $product->get_name();
$sku = $product->get_sku() ? $product->get_sku() : '';
$price = $product->get_price_html();
$stock = $product->get_stock_quantity() ?: 'In Stock';
$sold_count = get_post_meta($product_id, '_sold_individually', true) ? 'Sold: ' . get_post_meta($product_id, '_sold_count', true) : 'Sold: 0';
$link = get_permalink($product_id);
ob_start();
?>
★★★★★ 0 Reviews
Retail Price
KES
Quantity:
( Stock)
Skip to content