• I have a simply woocommerce shortcode that displays all featured products (no other filters). I use the WPC Product timer to set my product to Featured at given time. Everything works well in the backend (it is marked as featured), however, in the front end it is not displaying from my Woocommerce shortcode. ALso, if I manually set that same product as featured in the backend, then that product is displayed in the Woocommerce shortcode.

    Is this a know issue? I see someone else also posted this here , but I don’t if it was resolved.

Viewing 1 replies (of 1 total)
  • Plugin Author WPClever

    (@wpclever)

    Hi @tnbaker

    Thanks for informing us on this issue!

    Please update our plugin to the latest version 3.5.8 then add below snippet (How to add custom code?):

    add_filter( 'woocommerce_shortcode_products_query_results', 'woopt_shortcode_products_query_results', 99, 2 );
    function woopt_shortcode_products_query_results( $results, $shortcode ) {
    	if ( $shortcode->get_type() === 'featured_products' ) {
    		global $wpdb;
    		$products = $wpdb->get_results( "SELECT id FROM $wpdb->posts WHERE post_type = 'product' AND post_status = 'publish' LIMIT 500", OBJECT );
    		$exclude  = array();
    
    		if ( count( $products ) > 0 ) {
    			foreach ( $products as $pr ) {
    				$featured = has_term( 'featured', 'product_visibility', $pr->id );
    
    				if ( WPCleverWoopt::woopt_is_featured( $featured, $pr->id ) ) {
    					array_push( $results->ids, $pr->id );
    				} else {
    					array_push( $exclude, (int) $pr->id );
    				}
    			}
    
    			$results->ids = array_unique( array_diff( $results->ids, $exclude ) );
    		}
    	}
    
    	return $results;
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Set featured products not displaying’ is closed to new replies.