skip to Main Content

I’m using Shopify API to request the phone number of the user by using {{customer.phone}} as a checkout script, but the request gives me a number with whitespaces between numbers like this:
123 456 789

How can I remove whitespaces from this output?

2

Answers


  1. To modify a String you need to use a Shopify String filter. You can check out more details in the documentation: https://help.shopify.com/en/themes/liquid/filters/string-filters

    Below is a code which will return the phone numbers without spaces:

    {{ customer.phone | remove:" "}}
    
    Login or Signup to reply.
  2. if you want for example to convert:

    • 1,000.00 USD to 1000.00 you can use this code:
    {{ product.price_min| money_without_currency | remove:","}}
    • 1,000.00 USD to 1000 you can use this code:
    {{ product.price_min | money_without_currency | remove:"," | remove:"." | divided_by: 100}}
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search