Please submit a private ticket if you need to share sensitive information, such as license details and admin credentials.

Okay
  Public Ticket #3785477
Hide out-of-stock products
Open

Comments

  •  5
    Jesica started the conversation

    Hi, Dustin, how are you?

    What are the possibilities for hiding out-of-stock products in the recommended products from FlyCart? How can I add a specific class to those products, maybe by editing a file? I've tried using php and JS code, but it doesn't work.

     Thank you so much.

    Attached files:  Home - Beauty Now.png

  •  1,281
    Dustin replied

    Hi Jesica,

    Please add the custom code below. (How to add custom code? ↗):

    add_filter( 'woofc_suggested_products_before_limit', function ( $suggested_products ) {
    	foreach ( $suggested_products as $suggested_product_id ) {
    		$suggested_product = wc_get_product( $suggested_product_id );
    
    		if ( ! is_a( $suggested_product, 'WC_Product' ) || ! $suggested_product->is_purchasable() || ! $suggested_product->is_in_stock() ) {
    			$suggested_products = array_diff( $suggested_products, [ $suggested_product_id ] );
    		}
    	}
    
    	return $suggested_products;
    } );

    Best regards,
    Dustin

  •  5
    Jesica replied

    We love you so much.