Change text on Add to Cart Button to include a space

Solved

Change text on Add to Cart Button to include a space

hideandscratch
Visitor
2 0 1

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. 

hideandscratch_0-1725630213646.png

 

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

hideandscratch_0-1725630401309.png

 

 

 

 

Accepted Solution (1)

namphan
Shopify Partner
1120 139 173

This is an accepted solution.

Hi @hideandscratch,

Please change code:

<span class="ezfyButtonPrice">{{ product.selected_or_first_available_variant.price | money }}</span>

=>

<span class="ezfyButtonPrice" style="padding-left: 5px;">{{ product.selected_or_first_available_variant.price | money }}</span>
Coffee tips fuels my dedication.
Shopify Development Service
Need help with your store? namphan992@gmail.com

View solution in original post

Replies 7 (7)

BSS-TekLabs
Shopify Partner
2093 618 723

Hello @hideandscratch 
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.

If our suggestions are useful, please let us know by giving it a like or marking it as a solution.


Salepify: Efficiently increase sales conversion with sale-driven features like auto add to cart, free gifts (free plan available)

BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now

topnewyork
Globetrotter
633 113 134

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

Need a Shopify developer?
Hire us at Top New York Web Design
For Shopify Design Changes | Shopify Custom Coding | Custom Modifications
Subscribe to our youtube channel

namphan
Shopify Partner
1120 139 173

This is an accepted solution.

Hi @hideandscratch,

Please change code:

<span class="ezfyButtonPrice">{{ product.selected_or_first_available_variant.price | money }}</span>

=>

<span class="ezfyButtonPrice" style="padding-left: 5px;">{{ product.selected_or_first_available_variant.price | money }}</span>
Coffee tips fuels my dedication.
Shopify Development Service
Need help with your store? namphan992@gmail.com
hideandscratch
Visitor
2 0 1

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

namphan
Shopify Partner
1120 139 173

Hi @hideandscratch,

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

Coffee tips fuels my dedication.
Shopify Development Service
Need help with your store? namphan992@gmail.com

ReturnPrime
Shopify Partner
481 67 108

Hi @hideandscratch ,

 

 

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

BSSCommerce-B2B
Shopify Partner
1425 397 458

@hideandscratch , you can add after this

BSSCommerceB2B_0-1725632088301.png

this code 

&nbsp;

It will add a space for your add to cart button

B2B Wholesale Solution: Streamline your B2B operation with advanced features like wholesale registration forms, custom pricing.


B2B Portal, Quote, Net 30: Speed up purchasing and streamline your quotation process with advanced features like quick order, request for quote.


B2B Lock Password Protect: Easily control access to pages, products, and pricing with robust features.


BSS Commerce - Full-service eCommerce Agency I Use Shopify for 1$ in the first month now