Home Forums WoodMart support forum Product "out of stock" show with blank space

Product "out of stock" show with blank space

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #236847

    MG Group Italia
    Participant

    Hi,
    I had some issue with products “out of stock”…In some case the products is hidden but the with empty space. I want to exclude them from the result

    Example in attachment

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

    Hello,

    Thank you very much for choosing our theme and for contacting us.

    “Our of stock” is Wocoomerce functionality and our theme does not influence that.

    I am checking on my site, I have enabled “Hide out of stock items from the catalog” in the Woocommerce > Settings > Products > Inventory and there is no gap in the shop page or in the Product element. Do you mean this option?

    Best Regards

    #236990

    MG Group Italia
    Participant

    I’d enable “Hide out of stock items from the catalog” but in some page or element like shop page or in “AJAX Product tabs” the products is skipped.

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

    MG Group Italia
    Participant

    If I disable the option “Hide out of stock items from the catalog” all products is show in the post grid with banner “Out of stock”

    #237051

    Hello,

    Please provide your site admin access to the private area. I will check the settings.

    Best Regards

    #237070

    MG Group Italia
    Participant

    Adding this code to functions.php seams that the empty space are fixed in shop page

    add_action( ‘woocommerce_product_query’, ‘custom_woocommerce_product_query’ );
    function custom_woocommerce_product_query( $q ) {
    if ( ! is_admin() ) {
    $oos_query = new WP_Query( [
    ‘meta_query’ => [ [
    ‘key’ => ‘_stock_status’,
    ‘value’ => ‘outofstock’,
    ‘compare’ => ‘=’,
    ], ],
    ‘post_type’ => ‘product’,
    ‘posts_per_page’ => -1,
    ‘fields’ => ‘ids’,
    ] );
    $exclude_ids = $oos_query->posts;

    $q->set( ‘post__not_in’, $exclude_ids );
    }
    }

    Now the problem is still present in “Ajax product tabs” and in the category widget (mismatch products count)

    #237112

    Hello,

    That is fine! If you have any questions please feel free to contact us.

    Best Regards

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

The topic ‘Product "out of stock" show with blank space’ is closed to new replies.