Home Forums WoodMart support forum In stock

In stock

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #532212

    wooblycommerce
    Participant

    Hi,
    how to set in the filters that the In-stock filter is always ON.

    Is there any option or we need to use code (give what code to use)

    Attachments:
    You must be logged in to view attached files.
    #532325

    Luke Nielsen
    Keymaster

    Hello,

    Sorry to say but right now there is no option in Theme Settings available for that. It requires Customization and this is beyond our limitations and support policy scope. Hope you can understand our limitations.

    Let me know if you have any additional questions.

    Best Regards.

    #532821

    wooblycommerce
    Participant

    Only solution is this, use this php code:

    /**
    * Display only in-stock products in WooCommerce.
    */
    function display_only_in_stock_products( $query ) {
    if ( ! is_admin() && $query->is_main_query() && ( is_shop() || is_product_category() || is_product() ) ) {
    // Set the query to show only in-stock products
    $query->set( ‘meta_query’, array(
    array(
    ‘key’ => ‘_stock_status’,
    ‘value’ => ‘instock’,
    ‘compare’ => ‘=’,
    ),
    ) );
    }
    }
    add_action( ‘pre_get_posts’, ‘display_only_in_stock_products’ );

    #533010

    Luke Nielsen
    Keymaster

    Hello,

    Glad that you found the solution.

    Feel free to contact us if you have any questions.

    Have a good day!

    Kind Regards

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘In stock’ is closed to new replies.