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.