• Resolved Mr_sordum

    (@paulcityhopper)


    A category got a lot of items with stock “out of stock”.
    If I enable the function “woocommerce_hide_out_of_stock_items” in WooCommerce -> Settings -> Products the amount of items is correct, BUT items per page is not working correct.

    Example:
    – 20 items per Page
    – 32 items which are in stock

    What happen:
    – 5 pages (first page 3 items, second 5 items, …)

    If I disable this function, everything is working correct.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Mr_sordum

    (@paulcityhopper)



    Code below is helping, so maybe there is an issue with the category (term) loop?

    function filter_out_of_stock_prod($q, $wc_query){
    
    $meta_query = $q->get( 'meta_query' );
    $meta_query[] = array(
    'key' => '_stock_status',
    'value' => 'instock',
    'compare' => '='
    );
    
    $q->set( 'meta_query', $meta_query );
    }
    add_action( 'woocommerce_product_query','filter_out_of_stock_prod', 10, 2);
    Plugin Support ckadenge (woo-hc)

    (@ckadenge)

    Hello @paulcityhopper,

    I understand you’re experiencing issues with the “woocommerce_hide_out_of_stock_items” function and the items per page display when the function is enabled.

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    All the best!

    Thread Starter Mr_sordum

    (@paulcityhopper)

    Hey,

    I dont need help. I want to report a bug.

    Regards
    Paul

    Hey, @paulcityhopper!

    I dont need help. I want to report a bug.

    Thank you for reporting it, but I was not able to replicate this issue on my website.

    The products show correctly on the shop page with the option to hide out of stock products.

    Can you please run a conflict test to see if something external is interfering with this?

    To test, you’ll first want to change the theme on your site to Storefront, then check to see if the issue is still present. If that resolves the issue, you’ll want to get in touch with your theme’s developer and see if they have an update or fix for you.

    If changing the theme doesn’t help, you’ll want to deactivate all plugins except for WooCommerce and take a look. If that fixes the problem, re-enable the other plugins one by one (gradually), checking after each, to see where the issue is coming from.

    — Be sure you have a good backup in place of your full site and database. You can ask your host for backup functionality or you can consider using a service like Jetpack. If something goes wrong, you will be able to restore it.

    — Also, you can consider using a plugin like Health Check & Troubleshooting. This is a plugin developed by the WordPress community and it is helpful to disable plugins without affecting your current site visitors.

    — It is important to consider as well a staging functionality in case you would not like to touch your production site (you can ask your host if they offer this service), or you can use WP Staging for quickly spinning up a new test site.

    You can find more about this in this guide.

    Please let us know about your findings.

    Looking forward to your reply.

    Have a wonderful day!

    Hi there ?? We haven’t heard back from you in a while, so I’m going to mark this as resolved – we’ll be here if and/or when you are ready to continue.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘“woocommerce_hide_out_of_stock_items” when enabled items per page is wrong’ is closed to new replies.