How to Remove COMMA After COLOR Option in Cart Drawer? (Dawn theme)

Solved

How to Remove COMMA After COLOR Option in Cart Drawer? (Dawn theme)

Senku
Excursionist
14 0 5

How can I remove the COMMA that appears after the product option (COLOR) in the cart drawer? I'm using the Dawn theme. Would really appreciate any help!

 

Screenshot 2025-04-16 at 11.43.44.jpg

Accepted Solution (1)

namphan
Shopify Partner
2572 335 380

This is an accepted solution.

Hi @Senku,

Please go to Actions > Edit code > snippets > cart-drawer.liquid file, find 'item.product.has_only_default_variant' and remove code here:

Screenshot.png

Coffee tips fuels my dedication.
Shopify Development Service
PageFly Page Builder Optimize your Shopify store (Free plan available)
Need help with your store? namphan992@gmail.com

View solution in original post

Replies 15 (15)

Mustafa_Ali
Excursionist
327 24 53

hey @Senku share the URLs of your website plz

Senku
Excursionist
14 0 5

here is the website using the same theme, when you add to cart, you will see the cart drawer and the comma i want to remove: thttps://seasonalcollections.co/

Moeed
Shopify Partner
7335 1989 2424

Hey @Senku 

 

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

<script>
document.addEventListener('DOMContentLoaded', function() {
  const productOptionDivs = document.querySelectorAll('.product-option');

  productOptionDivs.forEach(function(optionDiv) {
    const dtElement = optionDiv.querySelector('dt');
    const ddElement = optionDiv.querySelector('dd');

    if (dtElement && dtElement.textContent.trim() === 'Color:' && ddElement) {
      ddElement.innerHTML = ddElement.innerHTML.replace(/,\s*$/, '');
    }
  });
});
</script>

RESULT:

Moeed_0-1744780773775.png

 

If I managed to solve your problem then, don't forget to Like it and Mark it as Solution!

 

Best Regards,
Moeed

- Need a Shopify Specialist? Chat on WhatsApp

- Get a quick Shopify quote – Click here!

- Custom Design | Advanced Coding | Store Modifications


tim
Shopify Partner
4246 481 1559

Looks like your theme code is already modified and theme does not auto update, so I'd suggest you edit your theme code, go to snippets/cart-drawer.liquid and delete the following line:

 {%- unless forloop.last %}, {% endunless %}

 

as highlighted here:

https://github.com/Shopify/dawn/blob/release/13.0.1/snippets/cart-drawer.liquid#L174 

If my post is helpful, consider liking it -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com

namphan
Shopify Partner
2572 335 380

This is an accepted solution.

Hi @Senku,

Please go to Actions > Edit code > snippets > cart-drawer.liquid file, find 'item.product.has_only_default_variant' and remove code here:

Screenshot.png

Coffee tips fuels my dedication.
Shopify Development Service
PageFly Page Builder Optimize your Shopify store (Free plan available)
Need help with your store? namphan992@gmail.com
Senku
Excursionist
14 0 5

can you help me with custom css? i don't want to change theme code

 

tim
Shopify Partner
4246 481 1559

This is indeed commendable.

 

You can't fix this with CSS alone because this comma is not  a separate element.

Moeed's code would not really work because content of the drawer is changed dynamically.

 

Try this. It's not a theme code edit -- Add a "Custom liquid" section to the footer section group and put the code to this section setting:

<script>
window.addEventListener('load', ()=> {
  let fixOptions = () => {
    requestAnimationFrame(()=>{
      document.querySelectorAll('.product-option dd').forEach(e=>{ e.innerHTML = e.innerHTML.replace(/,\s*$/, '');});
    });
  };

  fixOptions();
  window.subscribe && subscribe(PUB_SUB_EVENTS.cartUpdate, (data) => {
    let { source } = data;
    if (source!= 'product-form') fixOptions();
    else {
      let cartDrawer = document.querySelector('cart-drawer');
      if (cartDrawer) cartDrawer.addEventListener("transitionend",fixOptions);
    }
  });
});
</script>

 

 

If my post is helpful, consider liking it -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com

DaisyVo
Shopify Partner
4383 486 578

Hi @Senku 

You can try to follow this step
Step 1: Go to Edit code
Step 2: Find file base.css and add this code at the end of the file

 

td.cart-item__details dl .product-option:first-child {
    display: none !important;
}

 

Result 

DaisyVo_0-1744810763390.png

 

Best,

DaisyVo

Please let us know if our reply is helpful by giving it a Like or marking it as a Solution!

Avada SEO & Image Optimizer - The #1 SEO solution
Senku
Excursionist
14 0 5

will it only remove comma and not affect other functions in website right?

DaisyVo
Shopify Partner
4383 486 578

Hi @Senku 

 

In that case, you'll need to modify the theme's code — it can't be done with CSS alone. You should contact the theme developer to avoid any potential issues.

Please let us know if our reply is helpful by giving it a Like or marking it as a Solution!

Avada SEO & Image Optimizer - The #1 SEO solution
Senku
Excursionist
14 0 5

this way right? 

Step 1: Go to Edit code
Step 2: Find file base.css and add this codeat the end of the file: td.cart-item__details dl .product-option:first-child { display: none !important; }

 

tim
Shopify Partner
4246 481 1559

Nope. This is code edit and this will hide selected options completely rather than only comma.

 

If my post is helpful, consider liking it -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com
Senku
Excursionist
14 0 5

Thank you so much. This is the option that only remove comma and will not affect others right? 

Looks like your theme code is already modified and theme does not auto update, so I'd suggest you edit your theme code, go to snippets/cart-drawer.liquid and delete the following line: {%- unless forloop.last %}, {% endunless %}

tim
Shopify Partner
4246 481 1559

Yes. If your theme code is already modified, then this is the simplest solution to your initial problem.

If, however, you want to avoid theme code modifications, then use my other suggestion, via "Custom Liquid" section.

If my post is helpful, consider liking it -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com
Senku
Excursionist
14 0 5

Thanks a bunch!