Hide out of stock variations when filtering
-
Hi, I have the same problem many people face with Woocommerce. I made a Woocommerce shoe store for a customer (I run a web-agency). When filtering shoes by shoe size the results show ALL shoes that are available in that size REGARDLESS if that size is in stock. If customers search for shoes in size 43 they get a selection of shoes but when they click on one they often see that the specific shoes isn’t available in that size which is very frustrating for them. Do you already have a fix for this or a workaround I can use in this situation? Lot’s of people complain about this because filtering on product variations (shoe sizes in this example) should be a basic function in a webshop right?
I spend hours and hours browsing the internet for a solution but really nobody has a solution for this problem and I saw that a lot of people have the same issue with this. I read that this problem has to do with performance etc. but I would rather have a slow, functioning shoe store than a shoe store where people can’t even find a shoe in their size.
Thanks in advance.
William
-
Sorry to know that you are facing this problem. Did you check Hide out of stock items from the catalog setting under WooCommerce > Settings > Product > Inventory ? Is it not working?
Also, could you please share the website link?
Full system status report would help: https://www.ads-software.com/support/topic/before-posting-gather-the-following-details
Hi, Thanks for replying so fast. I did check that checkbox, didn’t work. I guess that only works when the product as a whole is out of stock, not when a couple of variations of that product are out.
The link of the website: https://birkenshop.be/product-categorie/birkenstock/sandalen/
The filter i’m talking about is: ‘Schoenmaat’ (that stands for shoe size in dutch) just select a shoe size and click a couple shoes, you’ll notice that the filter doesn’t look if the size is out of stock or not.system status report:
### WordPress Environment ### Home URL: https://birkenshop.be Site URL: https://birkenshop.be WC Version: 2.5.5 Log Directory Writable: ? WP Version: 4.5.3 WP Multisite: – WP Memory Limit: 512 MB WP Debug Mode: – Language: nl_NL ### Server Environment ### Server Info: Apache PHP Version: 5.5.35 PHP Post Max Size: 128 MB PHP Time Limit: 270 PHP Max Input Vars: 20000 SUHOSIN Installed: – MySQL Version: 5.6.24 Max Upload Size: 128 MB Default Timezone is UTC: ? fsockopen/cURL: ? SoapClient: ? DOMDocument: ? GZip: ? Multibyte String: ? Remote Post: ? Remote Get: ? ### Database ### WC Database Version: 2.5.5 : woocommerce_sessions: ? woocommerce_api_keys: ? woocommerce_attribute_taxonomies: ? woocommerce_termmeta: ? woocommerce_downloadable_product_permissions: ? woocommerce_order_items: ? woocommerce_order_itemmeta: ? woocommerce_tax_rates: ? woocommerce_tax_rate_locations: ? ### Active Plugins (32) ### Akismet: door Automattic – 3.1.11 Bloom: door Elegant Themes – 1.1.7 Cart2Cart: Password Migration: door MagneticOne – 1.0 Contact Form 7: door Takayuki Miyoshi – 4.4.2 Facebook Widget: door Milap Patel – 4.1 Imagify: door WP Media – 1.5.6 Multisafepay: door Multisafepay – 2.2.4 Multisafepay iDEAL: door Multisafepay – 2.2.4 Multisafepay Maestro: door Multisafepay – 2.2.4 Multisafepay MasterCard: door Multisafepay – 2.2.4 Multisafepay MisterCash: door Multisafepay – 2.2.4 Multisafepay VISA: door Multisafepay – 2.2.4 Quick Page/Post Redirect Plugin: door anadnet – 5.1.8 Regenerate Thumbnails: door Alex Mills (Viper007Bond) – 2.2.6 Smart Slider 3: door Nextend – 3.0.35 Tracking Code Manager: door IntellyWP – 1.10.12 WooCommerce Bulk Edit Product Variations: door matterico_themes – 2.5.3 Woo Checkout Field Editor Pro: door ThemeHiGH – 1.1.0 WooCommerce Bulk Stock Management: door WooThemes – 2.2.1 – 2.2.2 is beschikbaar WooCommerce MailChimp: door Adam Anderly – 1.3.7 WooCommerce PDF Invoices & Packing Slips: door Ewout Fernhout – 1.5.36 WOOF - WooCommerce Products Filter: door realmag777 – 1.1.5.1 Woocommerce Products Per Page: door Jeroen Sormani – 1.2.2 WooCommerce Sequential Order Numbers: door SkyVerge – 1.7.0 WooCommerce Smart Sale Badge: door Hugh Lashbrooke – 1.1 WooCommerce Stock Manager: door Vladislav Musílek – 1.0.9 WooCommerce: door WooThemes – 2.5.5 WP Add Custom CSS: door Daniele De Santis – 1.0.0 WP Rocket: door WP Rocket – 2.8.5 WP User Avatar: door flippercode – 2.0.7 YITH WooCommerce Dynamic Pricing and Discounts Premium: door yithemes – 1.0.3 YITH WooCommerce verlanglijst: door YITHEMES – 2.0.16 ### Settings ### Force SSL: – Currency: EUR (€) Currency Position: left Thousand Separator: Decimal Separator: , Number of Decimals: 2 ### API ### API Enabled: ? API Version: 3.1.0 ### WC Pages ### Winkelbasis: #55259 - /winkel/ Winkelmand: #5861 - /winkelmand/ Afrekenen: #5862 - /afrekenen/ Mijn account: #5864 - /mijn-account/ ### Taxonomies ### Product Types: external (external) grouped (grouped) simple (simple) variable (variable) ### Theme ### Name: Neighborhood Version: 3.3.1 Author URL: https://www.swiftideas.net Child Theme: ? – Als je wijzigingen aanbrengt in WooCommerce of in een hoofdthema dat je niet zelf gebouwd hebt raden we het gebruik van een subthema aan. Zie: Hoe maak je een subthema WooCommerce Support: ? ### Templates ### Overrides: neighborhood/woocommerce/archive-product.php neighborhood/woocommerce/cart/cart-empty.php neighborhood/woocommerce/cart/cart-totals.php neighborhood/woocommerce/cart/cart.php neighborhood/woocommerce/cart/cross-sells.php neighborhood/woocommerce/checkout/form-billing.php neighborhood/woocommerce/checkout/form-checkout.php neighborhood/woocommerce/checkout/form-shipping.php neighborhood/woocommerce/checkout/thankyou.php neighborhood/woocommerce/content-product.php neighborhood/woocommerce/content-product_cat.php neighborhood/woocommerce/content-single-product.php neighborhood/woocommerce/global/quantity-input.php neighborhood/woocommerce/loop/add-to-cart.php neighborhood/woocommerce/loop/loop-end.php neighborhood/woocommerce/loop/loop-start.php neighborhood/woocommerce/loop/result-count.php neighborhood/woocommerce/myaccount/form-edit-address.php neighborhood/woocommerce/myaccount/form-login.php neighborhood/woocommerce/myaccount/my-account.php neighborhood/woocommerce/myaccount/my-address.php neighborhood/woocommerce/order/order-details.php neighborhood/woocommerce/single-product/add-to-cart/external.php neighborhood/woocommerce/single-product/add-to-cart/grouped.php neighborhood/woocommerce/single-product/add-to-cart/simple.php neighborhood/woocommerce/single-product/meta.php neighborhood/woocommerce/single-product/product-image.php neighborhood/woocommerce/single-product/product-thumbnails.php neighborhood/woocommerce/single-product/related.php neighborhood/woocommerce/single-product/review.php neighborhood/woocommerce/single-product/tabs/additional-information.php neighborhood/woocommerce/single-product/tabs/description.php neighborhood/woocommerce/single-product/tabs/tabs.php neighborhood/woocommerce/single-product/up-sells.php neighborhood/woocommerce/single-product.php neighborhood/woocommerce/taxonomy-product_cat.php neighborhood/woocommerce/taxonomy-product_tag.php
What you are experiencing does seem off, but unfortunately it’s the way things are supposed to work.
You can read more about why here: https://github.com/woothemes/woocommerce/issues/6574
So what you are saying is that Woocommerce doesn’t allow filtering on product variations even if this is a key function like in a Shoe store, Clothing store, etc. People just have to scroll through the store and hope that the shoes they like are available in their size. This makes the customers have a very bad shopping experience.
Don’t get me wrong, I use Woocommerce all the time and only in this shop I ‘ve got troubles using it.
I read the article you’ve commented and it seems (by googled this problem) many people are having this issue. This article dates from 2 years ago though and Woocommerce hasn’t done anything to solve this failure in it’s functionalities.
It just disappoints me that Woocommerce doesn’t have a solution for this problem even though it is been there forever. The only solution would be to switch from Woocommerce to another e-commerce service but we just transferred the store from Magento to Woocommerce (because in many aspects Woocommerce was a beter option for this customer) a couple of month ago so that’s not an option either.
Guess i’m stuck with this problem?
> Guess i’m stuck with this problem?
Unfortunately, yes. The answer in that thread makes sense, as parsing through each variation on each filter change would, in turn, slow the site down…possibly to an unusable status, depending on the number of variations that would need to be read each time.
I agree, the answer in the article makes sense in terms of performance issues but that’s a rather silly excuse. From my experience as a webdeveloper Woocommerce is the only e-commerce platform that has this problem and they apparently refuse to do something about it. If the performance issue would be an unavoidable problem, why do other e-commerce platforms don’t have this bug then?
What I’m trying to accomplish here isn’t rocket science. It’s just a basic functionality of any e-commerce website with variations. If checking if a variation is in stock when filtering products is going to slow down or even crash your website Woocommerce is just coded badly, plain and simple. I assumed that a team as big as Woocommerce could manage to fix this error that has been going on for over 2 years or even longer.
Hi williamm095!
Have you solved the issue? I have the same whit my shoes store. I’m stuck, don’t know what to do…
- This reply was modified 7 years, 11 months ago by antondrob.
Hi antondrob,
Sadly enough I am unable to fix the problem myself and the Woocommerce makers resist making a fix for this..so no I havn’t been able to solve this.
I hope they are going to fix this bug soon but I doubt it since it’s been a problem for over 2 years.
William
Wierd. Very wierd logic, very inconvenient. I asked some woocommerce experts on freelance sites, they didn’t solve the problem.
Thanks for the answer!major problem for any clothing store as well. 5000 styles endless dissapointment for someone looking for a specific size!
Not sure a problem I encountered is related to this issue.
But from the Admin panel backend, the searching for products also retrieves
Out-of-Stock even though I am trying to add product to an order. The logic
does not sound good -> adding an out-of-stock product.Please see the detailed steps on www.ads-software.com forum.
https://www.ads-software.com/support/topic/in-order-form-add-products-not-working-correctly/
Did any one find a fix to the product filters issue? This is such a major problem for woocommerce, I have looked and looked on google for a solution but cannot find one.
Please help Woocommerce, your competitors Magento and Shopify can handle this why doesn’t WC??
thanks
Hi Sam, I feel you this is a mayor issue for lot’s of people. I eventually created my own solution with snippets I found on Google and my own CSS. If you want to try it, please be my guest. This first part you add to the functions.php file located in your theme folder. Everywhere you see ‘schoenmaat’ you just change that part to the slug of your attribute you want to hide out (schoenmaat is dutch for shoe size).
/* layered navigation hide out of stock items
*/
function product_in_stock($post, $product) {
if ($_GET[‘filtering’] == 1 && $_GET[‘filter_schoenmaat’] > 0 ) {
$STOCK = FALSE;
$slugmap = array();
$attribs = $product->get_variation_attributes();
$terms = get_terms( sanitize_title( ‘pa_schoenmaat’ ));
if($terms)foreach($terms as $term)$slugmap[$term->slug]=$term->term_id;
$available = $product->get_available_variations();
if($available)foreach($available as $instockitem){
if(isset($instockitem[“attributes”][“attribute_pa_schoenmaat”])){
if($instockitem[“attributes”][“attribute_pa_schoenmaat”] == $_GET[“filter_schoenmaat”] && $instockitem[“max_qty”]>0){
$STOCK = TRUE;
}
}
}
return $STOCK;
} else {
return true;
}
}
// Funciones para crear un div in/out of stock alrededor del producto
function check_if_out_of_stock(){
global $post,$product;
$stock = product_in_stock($post,$product);
$output = ‘<div class=”‘;
$output .= $stock?”instock”:”outofstock”;
$output .= ‘”>’;
$output .= $stock?””: “<span class=’out-stock’>” . __( ‘Not in stock’, ‘woocommerce’ ). “</span>”;
echo $output;
}
add_action( ‘woocommerce_before_shop_loop_item’, ‘check_if_out_of_stock’);Next up you add some css to your general stylesheet of the website. Usually under theme options in your wordpress backend.
.out-stock{display:none;}
.outofstock .product-image{opacity:0.2 !important;}
li.product:has( .outofstock ) {
display:none !important;
}This solution greys out the images of the products that aren’t available in that size by giving them a lower opacity. This doesn’t delete them from the search result but at least it’s clear to customers that those aren’t available. This was the best I could come up with so hopefully this works for you! Let me know if it works or not. Good luck!!
- The topic ‘Hide out of stock variations when filtering’ is closed to new replies.