WooCommerce Out-of-Stock Products Still Visible Despite BeTheme Child Theme Customizations

edited March 6 in WooCommerce

Hello, BeTheme support team,

I'm experiencing an issue with the BeTheme integration on my WooCommerce site (https://nicoleta.store).

Issue: Despite using WooCommerce's built-in settings, custom CSS, and PHP code within a child theme, products (or variations) marked as "out of stock" are still appearing in the shop listings, search results, and product filters.

Actions I've already attempted:

  1. Enabled WooCommerce’s default setting to hide out-of-stock products (unsuccessful).
  2. Used custom CSS:
.outofstock {
    display: none !important;
}
  1. Applied the following PHP snippet in a child theme:
add_action('pre_get_posts', function($query) {
    if (!is_admin() && $query->is_main_query() && (is_shop() || is_product_category() || is_product_tag() || is_search())) {
        $meta_query = $query->get('meta_query');

        if (!is_array($meta_query)) {
            $meta_query = array();
        }

        $meta_query[] = array(
            'key'     => '_stock_status',
            'value'   => 'outofstock',
            'compare' => '!='
        );

        $query->set('meta_query', $meta_query);
    }
});

I also used WooCommerce's recommended filter to hide out-of-stock variations:

add_filter('woocommerce_variation_is_in_stock', function($in_stock, $variation) {
    return $variation->is_in_stock() ? $in_stock : false;
}, 10, 2);

Additional Debugging Information:

  • PHP deprecated warnings related to dynamic property creation (Be_custom_branding from the becustom plugin).

Conclusion: The issue appears to be a conflict or incompatibility with BeTheme or another integrated component, preventing WooCommerce from hiding out-of-stock products as intended.

Could you please provide guidance on resolving this or suggest any necessary modifications to ensure that out-of-stock products or variations are hidden correctly?

Thanks for your prompt support!

Comments

Sign In or Register to comment.
This website uses cookies

We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you’ve provided to them or that they’ve collected from your use of their services.

Cookies are small text files that can be used by websites to make a user's experience more efficient.

The law states that we can store cookies on your device if they are strictly necessary for the operation of this site. For all other types of cookies we need your permission. This means that cookies which are categorized as necessary, are processed based on GDPR Art. 6 (1) (f). All other cookies, meaning those from the categories preferences and marketing, are processed based on GDPR Art. 6 (1) (a) GDPR.

This site uses different types of cookies. Some cookies are placed by third party services that appear on our pages.

You can at any time change or withdraw your consent from the Cookie Declaration on our website.

Learn more about who we are, how you can contact us and how we process personal data in our Privacy Policy.

Please state your consent ID and date when you contact us regarding your consent.