Change text on Add to Cart Button to include a space

Topic summary

Issue: After adding the product price to the Add to Cart button, the label displayed as “Add to Cart$xx.xx” with no space. Attempts to add spaces in theme content (e.g., after a colon) were stripped.

Proposed fixes:

  • In Liquid, include a trailing space inside the button label before the price: {{ 'Add to Cart ’ }}{{ product.price | money }}. This ensures a literal space.
  • If appended via JavaScript, concatenate with a space: 'Add to Cart ’ + productPrice.
  • Alternative suggestion: insert a non‑breaking space entity after the label (e.g.,  ), ensuring visible spacing.
  • One reply suggested minor formatting around the money filter (removing an extra space before | money), but this is not the core fix.

Outcome: The OP confirmed the simple trailing-space solution worked.

Other notes: Some responders requested the store URL/password to investigate, but this was unnecessary for the fix. Images were shared to illustrate the issue, but they aren’t required to apply the solution.

Status: Resolved; no further actions pending.

Summarized with AI on December 20. AI used: gpt-5.

I’ve figured out how to add the product price to my Add to Cart button (using this guide), but it’s currently displaying as “Add to Cart$xx.xx” with no space between the “Add to Cart” and “$xx.xx”

How can I add a space in here? I figured out how to change the default theme content from “Add to Cart” to “Add to Cart:” to add a colon (or a dash or whatever), but any spaces added after the colon are removed.

My current code where it calls the text to display looks like this:

1 Like

Hello @camalia
Our team is ready to help you.
Please share your website address and access password (if necessary) so that we can check and assist you.

Hi @camalia , kindly share your store URL. Thanks!

Hi @camalia ,

Please change code:

{{ product.selected_or_first_available_variant.price | money }}

=>

{{ product.selected_or_first_available_variant.price | money }}
1 Like

Hi @camalia ,

To fix the issue with the missing space between “Add to Cart” and the price, you can modify the code where the button text is set. Based on your description, the space is likely being removed due to how the code is structured. Here’s how you can add a space:

Find the part of your code that sets the button text, which probably looks something like this:

html

{{ ‘Add to Cart’ }}{{ product.price | money }}

To ensure there’s a space between “Add to Cart” and the price, modify it as follows:

html

{{ 'Add to Cart ’ }}{{ product.price | money }}

Notice the space between 'Add to Cart ’ and {{ product.price | money }}.

If you’re appending the price in JavaScript, you can add the space in the string directly like this:

javascript

button.innerHTML = 'Add to Cart ’ + productPrice;

Let me know if you need help applying this in your specific theme or setup!

Hyelladi
Return Prime

THANK YOU!!! I knew it was something easy!

@camalia , you can add after this

this code

 

It will add a space for your add to cart button

Hi @camalia ,

If you have any questions, you can contact me directly.
Nice to meet you :blush: