We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Add strike through for sold out variant with variant images - dawn theme

Solved

Add strike through for sold out variant with variant images - dawn theme

beginner0309
New Member
4 0 0

We changed some of our variant options to show as images instead of text, see below for example. Because of this change, now there is no way to differentiate from the variants that are sold out to those that are in stock unless you click on them. Can someone help me figure out a way to add a strikethrough for the variant images that are sold out? Thank you!

Screenshot 2025-06-24 at 11.26.33 AM.png

Accepted Solution (1)
CodingFifty
Shopify Partner
1102 161 190

This is an accepted solution.

Go to Online Store, then Theme, and select Edit Code.
Search for base.css/theme.css/style.css/main.css/custom.css file Add the provided code at the end of the file.

.product-form__input input[type='radio'].disabled + label.color-swatch:before {
  content: "";
  position: absolute;
  left: 0;
  border: 1px solid red !important;
  top: 50%;
  width: 100%;
  height: 2px;
  background-color: red;
  transform: rotate(-20deg);
  transform-origin: center;
  z-index: 10;
  pointer-events: none;
}

.product-form__input input[type='radio']:not(.disabled) + label.color-swatch:before {
  content: "";
  border: none;
}

CodingFifty_0-1750882486107.png

 

Coding Fifty || Shopify Partner
For any custom section queries, please visit: Fiverr Profile
Found my response useful? Like it and mark as Accepted Solution!
For additional discussions, reach out via: Email ID: codingfifty@gmail.com

View solution in original post

Replies 7 (7)

Shadab_dev
Shopify Partner
1583 83 173

If you did this on your own then i understand but if you like watched a tutorial or copy pasted code then this feature should have been there. Anyway please send your store url, will check if its doable with css, most probably we might need to modify code a bit to check for sold out variants and give a seperate class to it and add the css stylings, but mostly there are classes for such variants we can target it with that.

Buy me Coffee, if you feel i was helpful. Email Me here or WhatsApp me with this link for any help with shopify theme customizations or any project in web dev. If this is helpful, please Like and Accept the solution.
beginner0309
New Member
4 0 0

Here is a link to the page for example: https://annasui.com/products/lip-rouge

Shadab_dev
Shopify Partner
1583 83 173

Try adding this in base.css file at the very bottom

.product-form__input input.disabled + label:before{

width: 3px;

background: red;

height: 100%;

transform: rotateX(210deg);

left: 50%;

}

This should add like a cross out line on swatches that are unavailable. 

Buy me Coffee, if you feel i was helpful. Email Me here or WhatsApp me with this link for any help with shopify theme customizations or any project in web dev. If this is helpful, please Like and Accept the solution.

CodingFifty
Shopify Partner
1102 161 190

Hey! @beginner0309,

 

Since your variant options are now displayed as images, you'll need to add custom code to visually indicate sold-out variants. A common solution is to apply a CSS class (like sold-out) to out-of-stock variant image buttons and then use CSS to style them—such as adding a strikethrough, dimming the image, or overlaying a "Sold Out" label. You'll need to modify the JavaScript or Liquid code that renders your variant selectors so it checks inventory and adds the class accordingly.

Coding Fifty || Shopify Partner
For any custom section queries, please visit: Fiverr Profile
Found my response useful? Like it and mark as Accepted Solution!
For additional discussions, reach out via: Email ID: codingfifty@gmail.com
beginner0309
New Member
4 0 0

Would you be able to share what that code should be? I do not know enough to create this by myself. Appreciate your help!

CodingFifty
Shopify Partner
1102 161 190

This is an accepted solution.

Go to Online Store, then Theme, and select Edit Code.
Search for base.css/theme.css/style.css/main.css/custom.css file Add the provided code at the end of the file.

.product-form__input input[type='radio'].disabled + label.color-swatch:before {
  content: "";
  position: absolute;
  left: 0;
  border: 1px solid red !important;
  top: 50%;
  width: 100%;
  height: 2px;
  background-color: red;
  transform: rotate(-20deg);
  transform-origin: center;
  z-index: 10;
  pointer-events: none;
}

.product-form__input input[type='radio']:not(.disabled) + label.color-swatch:before {
  content: "";
  border: none;
}

CodingFifty_0-1750882486107.png

 

Coding Fifty || Shopify Partner
For any custom section queries, please visit: Fiverr Profile
Found my response useful? Like it and mark as Accepted Solution!
For additional discussions, reach out via: Email ID: codingfifty@gmail.com
beginner0309
New Member
4 0 0

This worked perfectly, thank you!!