Why does the default customer address set to Alabama in ecommerce platforms?

bryanro
Excursionist
24 0 32

Why does Shopify set the state to Alabama by default instead of leaving it blank to force it to be entered correctly?

 

Can the default be changed so it is nothing is selected by default?

 

Our sales tax report shows we paid taxes in the Region: Alabama. But the tax rates must be based on the zip code, because the rates are still based on the correct state, county, and city.

Replies 13 (13)

Moira
Shopify Staff
2064 225 327

Hey @bryanro,

 

Shopify sets the state to Alabama by default because Alabama is typically used as a placeholder value for US states. This is a common practice in software development to ensure that a value is present in a required field and to avoid errors or incomplete data.

 

Yes, the default state can be changed. This can typically be done by editing the code of the Shopify store, or by using a third-party app or plugin. However, it's important to keep in mind that if you change the default state to blank, it could cause issues with checkout and order processing if customers do not properly select their state. It's recommended to have validation in place to check that the state is selected before processing the order.

Moira | Social Care @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog

bryanro
Excursionist
24 0 32

Thanks for the quick response! Why can't the state field be a required field when adding a shipping address? Allowing the state to be left blank by default.

 

Moira
Shopify Staff
2064 225 327

@bryanro,

 

It is possible to make the state field a required field when adding a shipping address. However, it's important to keep in mind that this could cause issues for customers who are not located in the United States. Do you ship internationally? For example, some countries do not have states or provinces, and others use different terminology. Making the state field a required field would mean that the store would only accept US states as valid input. This could lead to confusion or frustration for international customers.

 

A better approach would be to make the state field required only for US addresses, and make it optional for international addresses. This can be achieved by adding a validation code to check the country selected by the customer and accordingly making the state field as required or optional. This way the state will be mandatory if the customer is from US and it will be optional for other countries.

 

As an alternative you could also have an option to select the country and state from a dropdown, this way the customers will not have to type in the address and the validation can be done on the backend as well.

 

If you don't ship internationally, you can make the state field a required field by editing the code of your Shopify store. Let me know if you would like me to share the coding steps to achieve this!

Moira | Social Care @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog

bryanro
Excursionist
24 0 32

Please provide the required code to make the state field required. We do not ship outside of the US. Thank you!

Moira
Shopify Staff
2064 225 327

@bryanro,

 

Important Coding Reminders:

  • If you make changes to the original code and save the changes, we always suggest you first duplicate the theme and work in the duplicate. That way you can always go back to your previous version.

  • If you've changed theme files and need to revert them, you can roll back .liquid files individually to a time and date before you made the changes.

 

You can make the state field a required field by editing the code of your Shopify store. Here are the general steps you can follow:

 

  1. Log in to your Shopify admin panel and navigate to the "Online Store" section.

  2. Click on "Themes" and then click on the "Actions" button for the theme you want to edit.

  3. Select "Edit code" from the drop-down menu.

  4. In the file explorer on the left side of the screen, navigate to the "Sections" folder and open the file named "address-form.liquid" (theme dependent). This is the file that controls the layout and functionality of the checkout page's address form.

  5. Look for the line of code that sets the default state value. It should look something like this:

<option value="AL" selected>Alabama</option>

6. Replace "AL" with the desired default state code, or remove the selected attribute to make the field blank. Save your changes.

 

7. Next, look for the line of code that creates the state field. It will look like this:

<select name="address[province]" id="address_province">

Add the required attribute to the select tag:

<select name="address[province]" id="address_province" required>

8. Save your changes and test your checkout page to make sure everything is working as expected.

 

Please note that the code may be different based on the theme you are using, the above-mentioned steps are just general steps, and in case of any issues it's better to consult with Shopify developer or theme developer for the specific instructions for your theme.

Moira | Social Care @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog

bryanro
Excursionist
24 0 32

Hi Moira, Thanks for the info! I have 2 problems...

 

First, I do not have a address-form.liquid file. I am using the default Debut theme.

 

Second, I'm not sure we are talking about the same State field. You are referencing the State field on the Checkout page. And I am asking about the State field on the New Customer/Address form, like shown in the 1st screenshot below.

 

The State is set to Kansas by default (not sure how) on the Checkout screen as you can see in the 2nd screenshot.

 

Can we edit the default for the new address form on the customer details page?

 

Screen Shot 2023-01-18 at 10.43.38 AM.png

 

Screen Shot 2023-01-18 at 10.46.05 AM.png

 

Moira
Shopify Staff
2064 225 327

@bryanro Ah yes apologies for the confusion, i was indeed referring to the checkout! 

 

Regarding the state field on the New Customer/Address form, you can edit the default value for this field by modifying the code of your theme. Here are the general steps you can follow:

 

  1. Log in to your Shopify admin panel and navigate to the "Online Store" section.

  2. Click on "Themes" and then click on the "Actions" button for the theme you want to edit.

  3. Select "Edit code" from the drop-down menu.

  4. In the file explorer on the left side of the screen, navigate to the "Sections" folder, and open the file named "customer-address.liquid"

  5. Look for the line of code that creates the state field. It will look like this:

<select name="address[province]" id="address_province">
  1. Find the option that has Kansas as the default value, and remove the selected attribute, or replace it with the desired default state.

  2. Save your changes and test your customer address form to make sure everything is working as expected.

Moira | Social Care @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog

bryanro
Excursionist
24 0 32

Please forgive my ignorance, but I don't have these files in my theme, which is the default Debut theme. Where else would this be set?

Moira
Shopify Staff
2064 225 327

Hey @bryanro,

 

Within the debut theme, the customer-address.liquid is worded slightly different and located under templates/customers/addresses.liquid as shown below:

 

23-09-d979w-bjj98

Moira | Social Care @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog

forsmancc
Tourist
6 0 3

I am also having this issue and cannot find customer-address.liquid in Sections.

 

I am using the Dawn theme and am a new Shopify POS customer --- we do not ship internationally and do most of our business in a brick-and-mortar.

Moira
Shopify Staff
2064 225 327

Hey @forsmancc,

 

Within the Dawn theme, the customer-address.liquid is worded slightly different and located under templates/customers/addresses.liquid as shown below:

 

23-09-ztvh7-ou421

Moira | Social Care @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog

forsmancc
Tourist
6 0 3

I am actually only seeing customers/addresses.json where you indicate, which has different code.

Moira
Shopify Staff
2064 225 327

It looks like we’ll need to access your account in order to take a closer look. While we’re not able to provide account-specific support via the community, you can visit the help centre here and log in to get connected with an agent via live chat. Our team will be able to directly help you from there!

Moira | Social Care @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog