fbpx
Want To Add Extra Images Per Product Variation For Free? Download Now

swatches displaying for disabled variations

Justin Mazur

Hi,

Have an issue where swatches are displaying for product variations that have been disabled. I want swatches to display for variations that are out of stock, but not when a variation is disabled in Woocommerce. I’ve tried adjusting various settings but can’t seem to solve this. Can you help please?

Here’s some screenshots and details to illustrate the problem:

For example, this variable product has 1 of the 2 variations disabled:

swatch-issue-screenshot1.png

 

But on the front end the swatch for this disabled variation is showing:

swatch-issue-screenshot2.png

 

Here’s my settings for the swatch plugin. I want it to display swatches for out of stock variations, but not disabled variations:

swatch-issue-screenshot3.png

 

How can I get your plugin to stop displaying swatches for disabled variations?

Thank you.

Hakik Zaman

Hi Edward,

Thanks for your clarification. We have so many requests to display the disabled variation with blurred and cross.

I have contacted our development team. As per the current coding structure, they are saying it will not sync logically when you have multi-layer attributes. For example: Color, Size, Pattern, Type, etc. Color: Red is enabled with the combination of Pattern: Square but you have disabled Color: Red with Size: S.

So, it is not possible at this moment to give an option to control this. But they will research, and if they find a solution, they will update the code and release a new version.

I hope this explanation will help.

Thank You

Justin Mazur

Hi Hakik,

Thanks for you prompt response.

In the example I showed above there are no multi-layer attributes. It’s just color. You must be looking at a different product.

I found another clue. I have a few products where swatches for disabled variations are hidden correctly. When I view the swatch selector in the back end, I see that those swatches all have a note next to them saying “not used for variation.” See screenshot below. But in fact those color attributes are assigned to disabled variations for that product.

Any idea what could be going on here and is it possible this points to a bug in your plugin?

 

Another thought–could we come up with a simple PHP function that would hide disabled variations? Even if we could just add a CSS class to any swatches that are associated with a disabled variation, I could hide them with a simple CSS rule.

Justin Mazur

It looks like that screenshot didn’t upload properly, let me try again here:

Justin Mazur

Still not seeing that screenshot, let me try another way:

Hakik Zaman

Hi Edward,

Sorry for the inconvenience. Please upload your screenshot here: https://paste.pics/

Then post directly the screenshot link on this reply thread.

Hope to hear from you soon.

Thank You

Hakik Zaman

Hi Edward,

Can you please share an exact product link to check this issue?

Hope to hear from you soon.

Thank You

Justin Mazur

I just checked that product and those swatches no longer say “not used for variation”–very odd.

But there must be some way I can hide swatches for variations that are disabled, while showing blurred/crossed out swatches for variations that are enabled but temporarily out of stock.

Hakik Zaman

Hi Edward,

Unfortunately, there is no workaround as per your request.

The problem is- you may have one attribute for example: color.

But we had to structure the codebase for thinking of the other cases.

Still, I have pushed our development team again. They will try to find a way to disable the attribute that is disabled from the backend. But, it may be possible for one attribute.

If they find a way to introduce this they will release an update.

Thank You

Justin Mazur

OK, thanks for checking. Tell your developers that all I need is a unique CSS class assigned to any swatch associated with a disabled variation (class=”disabled-variation” or something like that), which would enable me to hide the swatch easily with a CSS rule.

I’m tempted to try and create a little PHP function I could add to my functions.php file in my child theme that would do this, but I’m not sure how to programmatically identify the disabled variations. If one of your coders has 5 minutes to think about this I bet they could come up with something…

Hakik Zaman

Hi Edward,

I have already contacted our development team. Unfortunately, there is no way to achieve the output of the disabled variations.

If you are familiar with the PHP code, you can check the file woo-variation-swatches > includes > class-woo-variation-swatches-product-page.php line number 868 to 893.

Then you can understand it brings all the attribute term value of a product. After the values are loaded it checks the match values. Then it makes an attribute value unclickable if that specific value is disabled from the backend.

I hope this explanation will help you to understand the flow of the coding structure.

Thank You

Justin Mazur

OK, I’ll have a look at that code and maybe I can come up with a PHP function that resolves the issue. I’ll report back here.

Justin Mazur

I see you released a new version today (2.0.28) and the note says “Fix: Hide disabled variation attributes”

Does that mean your coders fixed the issue?

Will install the update on my development site and see! Thank you. Will report back.

Hakik Zaman

Hi Edward,

Yes, we have resolved the issue in 2.0.28.

Please check and let us know how it goes on your site.

Hope to hear from you soon.

Thank You