Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add state/county field to addresses #483

Merged
merged 3 commits into from
Oct 14, 2021
Merged

Add state/county field to addresses #483

merged 3 commits into from
Oct 14, 2021

Conversation

jacksleight
Copy link
Contributor

@jacksleight jacksleight commented Oct 13, 2021

This PR adds state/county support to the shipping and billing addresses.

Just like the zip/postal code this will allow a field named *_state (US) or *_county (UK). As SC defaults to *_zip_code for zip/postal code this mirrors that convention by defaulting to *_state.

I've also updated the PayPal gateway as the shipping address PayPal provides contains values for both city and state:

admin_area_2
A city, town, or village. Smaller than admin_area_level_1.

admin_area_1
The highest level sub-division in a country, which is usually a province, state, or ISO-3166-2 subdivision. Format for postal delivery. For example, CA and not California. Value, by country, is:
UK. A county.
US. A state.

https://developer.paypal.com/docs/api/orders/v2/

In most places SC uses the US named fields by default, but there are a couple of places where the UK named fields are used. I've mirrored these because I wanted to be consistent with the conventions already in place in SC, but I'm not sure if any of this needs to be tidied up for consistency?

  1. The order blueprint has UK named fields called *_county
    • This is because it already has *_postal_code fields, not *_zip_code fields
  2. The shipping docs page has a US named field called *_state but the placeholder is County
    • This is because it already has a *_zip_code field with a placeholder of Postal Code, not Zip Code
  3. The PP gateway sets a UK named field called *_county
    • This is because it already sets a *_postal_code field, not *_zip_code
    • I dont know if this is a problem or not, does that mean if you're using *_zip_code and *_state they wont be updated from the PP data?

Copy link
Owner

@duncanmcclean duncanmcclean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

However, I've actually already built this (but called regions instead) in v2.4, along with updated tax features.

I'm fine with introducing this in v2.3 but we'd need call it region instead of county/state.

src/Orders/Address.php Outdated Show resolved Hide resolved
@jacksleight
Copy link
Contributor Author

Ah no problem, I have updated it to region. Thanks for adding it to 2.3, it's something my client just highlighted as he would like county fields added to his site.

@duncanmcclean
Copy link
Owner

Thanks! I'll review this properly tomorrow evening!

@duncanmcclean duncanmcclean merged commit 767f726 into duncanmcclean:2.3 Oct 14, 2021
duncanmcclean added a commit to duncanmcclean/sc-starter-kit that referenced this pull request Oct 14, 2021
@duncanmcclean
Copy link
Owner

Released in v2.3.47

@jacksleight jacksleight deleted the address-state branch October 14, 2021 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants