Hide variants with single option

Solved

Hide variants with single option

ElectricWitch
Tourist
6 0 3

Hey guys, have tried to edit theme to hide colour variants with single option as per other posts but cant get it to work. We have colour option with only 1 option - black on all our products. Would like to hide variants with only one option. We need to keep the variant there for our print on demand, but yeh want it hidden on front end. Any help would be appreciated!

 

website is --> www.electricwitch.com.au

Accepted Solutions (2)

Moeed
Shopify Partner
5457 1477 1764

This is an accepted solution.

Hey @ElectricWitch 

 

Follow these Steps:

1) Go to Online Store
2) Edit Code
3) Find theme.liquid file

4) Add the following code in the bottom of the file above </body> tag

<style>
fieldset.variant-picker__option.no-js\:hidden:nth-child(1) {
    display: none !important;
}
</style>

RESULT:

Moeed_0-1726484357589.png

 

If I managed to help you then, don't forget to Like it and Mark it as Solution!

 

Best Regards,
Moeed

- Need a Shopify Specialist? Chat on WhatsApp

- Custom Design | Advanced Coding | Store Modifications


View solution in original post

Moeed
Shopify Partner
5457 1477 1764

This is an accepted solution.

Hey @ElectricWitch 

 

Keep the previous code and add this new code above </style> in the end of the theme.liquid file.

.variant-picker .h-stack.gap-2 {
    display: none !important;
}

RESULT:

Moeed_0-1726484790903.png

 

If I managed to help you then, don't forget to Like it and Mark it as Solution!

 

Best Regards,
Moeed

- Need a Shopify Specialist? Chat on WhatsApp

- Custom Design | Advanced Coding | Store Modifications


View solution in original post

Replies 10 (10)

Moeed
Shopify Partner
5457 1477 1764

This is an accepted solution.

Hey @ElectricWitch 

 

Follow these Steps:

1) Go to Online Store
2) Edit Code
3) Find theme.liquid file

4) Add the following code in the bottom of the file above </body> tag

<style>
fieldset.variant-picker__option.no-js\:hidden:nth-child(1) {
    display: none !important;
}
</style>

RESULT:

Moeed_0-1726484357589.png

 

If I managed to help you then, don't forget to Like it and Mark it as Solution!

 

Best Regards,
Moeed

- Need a Shopify Specialist? Chat on WhatsApp

- Custom Design | Advanced Coding | Store Modifications


ElectricWitch
Tourist
6 0 3

Legend mate, that was so quick, worked perfect. thankyou!

ElectricWitch
Tourist
6 0 3

would u know how to hide the size read out also? for example 'Size:XL'

Moeed
Shopify Partner
5457 1477 1764

This is an accepted solution.

Hey @ElectricWitch 

 

Keep the previous code and add this new code above </style> in the end of the theme.liquid file.

.variant-picker .h-stack.gap-2 {
    display: none !important;
}

RESULT:

Moeed_0-1726484790903.png

 

If I managed to help you then, don't forget to Like it and Mark it as Solution!

 

Best Regards,
Moeed

- Need a Shopify Specialist? Chat on WhatsApp

- Custom Design | Advanced Coding | Store Modifications


ElectricWitch
Tourist
6 0 3

perfect mate appreciate your help!

Moeed
Shopify Partner
5457 1477 1764

Thank you for your reply. I'm glad to hear that the solution worked well for you. If you require any more help, please don't hesitate to reach out. If you find this information useful, a Like would be greatly appreciated.

- Need a Shopify Specialist? Chat on WhatsApp

- Custom Design | Advanced Coding | Store Modifications


ElectricWitch
Tourist
6 0 3

Hey mate, turns out this wont work on some items that dont have a colour option....it goes ahead and hides all the sizes because they are variant #1 on these products.  i need to filter out any variant with only one option. . I believe i need to edit the variant-picker.liquid to do this. would you be able to help with that at all?

Moeed
Shopify Partner
5457 1477 1764

Hey @ElectricWitch 

 

I see, it's causing some issues. Can you share your collaborator request code in private messages so I can help you out properly?

 

Best Regards,

Moeed

- Need a Shopify Specialist? Chat on WhatsApp

- Custom Design | Advanced Coding | Store Modifications


websensepro
Shopify Partner
1221 136 156

Hi @ElectricWitch ,

 

1. Go to Online Store -> Theme -> Edit code.
2. Open your theme.liquid file
3. In theme.liquid, paste the below code before </head>

 

<style>
fieldset.variant-picker__option.no-js\:hidden:nth-child(1) {
    display: none !important;
}
</style>

 

If my reply is helpful, kindly click like and mark it as an accepted solution.

Thanks!

Need a Shopify developer?
Hire us at WebSensePro
For Shopify Design Changes | Shopify Custom Coding | Custom Modifications
Subscribe to our youtube channel or buy us a Cofee here

Free Shopify Beginner Tutorial
ElectricWitch
Tourist
6 0 3

Thanks, but this always hides the first variant. I need to hide variants with only 1 option, regardless of the position. How would I do this?