Swatch class when out of stock
-
Hello,
Would it be possible to add some logic to your swatch function woodmart_swatches_list in order to check for variation stock status and then add a CSS class to the swatch if it is out of stock?
Right now it is very confusing if a variation is out of stock, but it is still selectable. With a CSS class applied to the swatch, I would gray it out or make it unselectable.
You can use default woocommerce class variation_is_active() to accomplish this, and it would be very helpful for the swatches.
https://github.com/woocommerce/woocommerce/blob/826af31e1e3b6e8e5fc3c1004cc517c5c5ec25b1/includes/class-wc-product-variation.php#L486
Hello,
Attributes selecting is the Woocommerce functionality our theme just suggest the visual way of presenting on the product page. The default Woocommerce does not suggest any options thereon, so you will have to find a plugin for that.
Best Regards
From my understanding, the swatches are a custom woodmart function correct? Any out of stock functions that work for the default woocommerce do not influence the woodmart swatches…
Hello,
Swatches are a custom view of Woocommerce functionality. Selecting swatches is still Woocommerce functionality which the theme does not influence.
Best Regards
Could you please direct me to where woocommerce creates the swatches? Is it a template?
Because as far as I can tell, it’s not default woocommerce behavior to have swatches. I thought it was a woodmart function that added the ability.
We mean that variations are WooCommerce functionality. We just transform select options to colored buttons.
Ah thanks! I didn’t realize how that worked.
For anyone else looking for a solution, this snippet works wonderfully!
https://pluginrepublic.com/display-stock-variations-unavailable-woocommerce/
Hello,
Thanks for sharing the information. If you have any questions please feel free to contact us.
Best Regards
The topic ‘Swatch class when out of stock’ is closed to new replies.