• KoolPal

    (@koolpal)


    Hi,

    I tried to use the code snippet at this thread https://wordpress.org/support/topic/remove-in-stock-status/ but my request uses another code.

    I am using a filter using woocommerce_get_availability

    How do I EXCLUDE Pre-Order products in the line below?

    if ( $product->get_manage_stock() && $stock_quantity <=4 ) {

    Please guide me.

    Thanks a lot.

Viewing 1 replies (of 1 total)
  • Plugin Support Alberto Martin

    (@albertomrtn)

    Hi @koolpal, using the following code, you can get if a product is a pre-order product:

    if ( class_exists( 'YITH_Pre_Order_Product' ) ) {
    	add_filter( 'woocommerce_get_availability', 'get_is_pre_order', 10, 2 );
    
    	function get_is_pre_order( $array, $instance ) {
    		$pre_order   = new YITH_Pre_Order_Product( $instance->get_id() );
    		$is_preorder = $pre_order->get_pre_order_status();
    	}
    }

    If $is_preorder is “yes”, then is a pre-order product.
    Now you would have to use that variable in your IF condition.

Viewing 1 replies (of 1 total)
  • The topic ‘Modify “In Stock” Status’ is closed to new replies.