Home Forums WoodMart support forum Swatch class when out of stock

Swatch class when out of stock

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #109500

    Joe
    Participant

    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

    #109509

    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

    #109511

    Joe
    Participant

    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…

    #109516

    Hello,

    Swatches are a custom view of Woocommerce functionality. Selecting swatches is still Woocommerce functionality which the theme does not influence.

    Best Regards

    #109521

    Joe
    Participant

    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.

    #109562

    Artem Temos
    Keymaster

    We mean that variations are WooCommerce functionality. We just transform select options to colored buttons.

    #109593

    Joe
    Participant

    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/

    #109627

    Hello,

    Thanks for sharing the information. If you have any questions please feel free to contact us.

    Best Regards

Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘Swatch class when out of stock’ is closed to new replies.