How to hide variant if there is online one available

Hi so I am trying to remove the variant like the USB one, since there is only one and i don’t want to delete the variant but more just to hide it. My website is Pixeoprint.com

Hey @Jeanne8

Head to Online Stores> Themes> Edit Code

open file called theme.liquid and just before the end of body tag paste this code

{% if product.variants.size <= 1 %}
      
    {% endif %}

If you are unable to implement the same then I’m happy to do this for you, let me know. I can implement the code changes so that this will work well for you.

Hopefully, it will help you. If yes then Please don’t forget to hit Like and Mark it as the solution!

Hi,

Thank you for answering! What is ‘‘before the end of body tag’’? I tried copy pasting at then end but it’s style there.

Prefer this screenshot

Thank you for reply. I just did it but it didn’t changed

Hi, are you still there?

Hi @Jeanne8 ,

You can try this code by following these steps:

Step 1: Go to Online Store->Theme->Edit code.

Step 2: Search file theme.liquid

Step 3: Paste the below code at the bottom of the file → Save

<style>
.swatch--gl:has([data-name="Electrical Outlet"]){
display:none !important
}
</style>

Hope my solution works perfectly for you!

Best regards,

Oliver | PageFly