"RuffRuff 予約販売" supports the reduction of opportunity losses that occur when products are out of stock, new products are not on sale, or are on backorder.
It's incredibly easy to create pre-orders on your Shopify store, allowing you to register an unlimited number of pre-order products and accept unlimited pre-orders. You can also restrict people from ordering pre-order items and regular items at the same time, or send notifications when the item will be back in stock if it is not yet determined.
There are many unique features that are not found in other pre-order sales apps, such as the "Pay Later" feature that allows you to collect payment before the product is shipped.
My name is Ogasawara and I am CTO at Tsun Inc.!
Recently, I have been developing apps and themes for Shopify.
In this blog, we will share information useful for Shopify development.
I would be happy if this would be helpful for Shopify engineers!
Why do this?
In some cases, phone numbers managed by Shopify (customer.phone, shipping_address.phone, etc.) include a country code (81 for Japan).
This can happen when customer data is edited from Shopify admin or when customers enter it themselves (probably a rare case).
I wanted to remove the country code when displaying phone numbers in the store or on forms, so I looked into how to do it!
As discussed in the Shopify Community thread https://community.shopify.com/c/General discussion/About problems with domestic delivery service due to correction of international phone number when manually adding a customer/td-p/878158, there is no option to save phone numbers with the country code removed, so if you need to remove it, you have to do so yourself when displaying the phone number.
How to do it
Apply the following filter to phone numbers in Liquid.
{{ shipping_address.phone | replace: '+811', '01' | replace: '+812', '02' | replace: '+813', '03' | replace: '+814', '04' | replace: '+815', '05' | replace: '+816', '06' | replace: '+817', '07' | replace: '+818', '08' | replace: '+819', '09' | replace: '+810', '0' }}
shipping_address.phone Please replace the part with your phone number.
What we're doing is simple: if +81 is added at the beginning, remove +81, and if the number does not start with 0, add 0. (If you edit it from Shopify admin, Shopify should remove the 0, but this is just in case.)
Liquid's replace filter doesn't support regular expressions, so I'm using brute force. If you can use regular expressions, you can make it even smarter, but let's hope for an update to Liquid.
Summary
This time, we introduced how to use Liquid's replace filter to remove country codes from phone numbers before displaying them.
We will be posting small stories like this from time to time, so please check back.