Hide out of stock variants on Canopy Theme

Hi,

Does anyone know if it’s possible to hide out-of-stock variants on the canopy theme automatically when they are out of stock?

Thank you

Hey @LWSOnline ,

I referred to the original theme and tested this, you’ll have to test it out yourself.

Go to your Theme customizer and in it’s settings paste this into the Custom CSS box and save it

ul#clickyboxes-option-color li:has(> .unavailable) {
    display: none !important;
}

Hi @ThePrimeWeb

Thanks for your reply. I’ve just given this a try and It doesn’t seem to be working. We are using the colour swatches, not sure if the code would need tweaking for this?

Thanks for your help.

No problem. If you can provide the store URL, I can just quickly check what needs to be done.

No problem, hopefully this share link works as we haven’t gone live with it yet.

https://oroqh6eutfazdap7-80345071940.shopifypreview.com/products/stylecraft-special-dk-100g?_pos=1&_psq=%20special%20dk&_ss=e&_v=1.0&variant=47791792881988

I don’t suppose you also know whether it’s possible to make the circle around the selected colour swatch more obvious too? at the moment you can’t really tell what is selected without scrolling up to the main image.

We did want a sticky add-to-cart button that stops sticking once you get to the bottom of the swatches or maybe a sticky main image to make it better to view on products with a lot of colours but have struggled to find something that works on all fronts theme-wise.

Thanks for your help it’s really appreciated.

Hey @LWSOnline ,

This worked for me.

First CSS code is to hide out of stock items

Second CSS code is to make the selected item more obvious.
Third CSS code will make your the gallery sticky on scroll until the end of the swatches.

ul#clickyboxes-option-colour li:has(> .unavailable) {
    display: none !important;
}

.product-form .selector-wrapper.selector-wrapper--swatch.selector-wrapper--swatch-image a.active {
    box-shadow: 0 0 0 4px #888 !important;
}

.product-gallery.half.column {
    position: sticky;
    top: 15px;
}

Thank you so much, it’s working much better on the desktop end now. I’ve just had a look on the mobile site thought and there seems to be an issue where the swatches are going in front of the main image instead of behind, any idea how to fix this?

Thanks

Hey @LWSOnline ,

Sorry I missed out the mobile part,
Here’s the CSS code in full again fixing the mobile issue. You can remove the previous one and paste this instead

ul#clickyboxes-option-colour li:has(> .unavailable) {
    display: none !important;
}

.product-form .selector-wrapper.selector-wrapper--swatch.selector-wrapper--swatch-image a.active {
    box-shadow: 0 0 0 4px #888 !important;
}

.product-gallery.half.column {
    position: sticky;
    top: 15px;
}

@media only screen and (max-width: 768px) {
    .product-gallery.half.column {
        position: initial;
    }
}

Thank you!

I noticed on products we are using other variant types like dropdowns, the out of stocks are still showing, is there a way to tweak it so it hides on all types?

Could you show me one of those products? I can take a look.
Also any other products with other variant types

Yes please see the link below. Thank you

https://2z0iozpp22etqd0b-80345071940.shopifypreview.com/products/knitpro-waves-soft-grip-crochet-hook?_pos=1&_psq=%20waves&_ss=e&_v=1.0

Hey @LWSOnline ,

There doesn’t seem to be any distinct difference to highlight out of stock options in the dropdown menu. It would be possible by editing the site’s Liquid code, but it’s better for you to switch this to a swatch also so that the above CSS code works with it automatically.

No worries, thanks for your help!

Hi @ThePrimeWeb

Sorry to bother you again. I don’t suppose you know how we can set the product image on the product page to remain contained in a square? Currently the box changes size for every variant you click.

Hey @LWSOnline ,

You can share the link to your store if you need it coded.

Also, I would rather you resize the actual images to make all of them the same size rather than limiting it by code because it removes your flexibility next time if you decide to do rectangular pictures, it won’t allow you since the code forces square.

Hi

Thank you for your reply. Our preview link is:

https://4320e6-3.myshopify.com/?_ab=0&_fd=0&_sc=1&key=ef327d0d37d4181fc4c10349d57ce0a106bec1382ddd56fdb657fae18e9c0d4a&preview_theme_id=157419929924

We do make all new images square now and plan to in the future. At the moment we have thousands of older product images that are all different sizes which are causing issues. We do plan to eventually go through all of them and change them to square but sadly we don’t have the time right now so we are hoping for a quick fix as we are eager to go live sooner rather than later.

Thanks for your help.

Hello

Looking into this as well, did you manage to get it working? If so were does the code changes go as was not able to figure it out from the given info.

Thanks in advance

Hi

@PaddyX The code has changed slightly in the newer update of canopy. The one we are using is:

.is-unavailable + .opt-label--swatch {
  display: none;
}

Paste it into the Custom CSS box in the theme editor.

thanks for the quick responce! Have tried it now and does not seem to have had any effect. Or may be having part effect, when search and in some views based on search we still see Sold out items. Or would this be specific to varients within a product and not the whole if no variant had stock.. Not sure what the latest canopy version is, we are on Canopy 4.2.1

WOW! Looks like has not been showing there were updates for some time, see the latest version is 7.0.1 and reading so far looks like v6 required a complete re-config of the theme so update to the ltest would need compleat re-build! wow, this will take a long time to process as there not only did we customise alot we also have a few script updates that either way would have to be manualy ported. Is there any route to for the upgrade process to remove some of the pain as we recall the last update also created mass head ache!