Get the Shopp Featured Products

This function will return the shopp objects that are tagged as featured in an array.  Once the objects are returned you can use the shopp() function, when looping through the array, to return the tag for the product (see https://shopplugin.net/api/shopp/).  This will be faster than looping through all the products looking for ones that are tagged as featured. Especially if you have a lot of products in the database.


function get_featured_products() {
global $wpdb;
$the_products = array();
$products = $wpdb->get_results("SELECT product FROM {$wpdb->base_prefix}shopp_summary WHERE featured = 'on'");
foreach($products as $product) {
array_push($the_products, shopp_product($product->product));
}
return $the_products;
}

https://gist.github.com/WazzaJB/6081661

Scroll to Top