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

Commerce V4, Address Validation Fails - Calling Unknown Method SalesTaxService:getState() #49

Closed
curtismorte opened this issue Aug 10, 2022 · 1 comment

Comments

@curtismorte
Copy link

Hey Guys,
There's a bug with the address validation controller endpoint: actions/avatax/json/validate-address

Before making your plugin compatible with Commerce v4, you had the following method inside of SalesTaxService.php:

private function getState(Address $address)

Since Craft Commerce no longer controls Addresses (they are a part of Craft CMS now), the model for Address changed. In doing so, the stateId / stateText field is no longer used.
You can read more on countries and states here.

It's my understanding that administrativeArea is now the appropriate field on the Address model for what most people consider a state / province. From the Craft CMS link above:

While Commerce has removed support for managing custom countries and states, the commerce/upgrade command prompts you to map the custom countries to real country codes, and copies the state abbreviation (if a custom state was created) or the stateName entered by the customer to the administrativeArea field on relevant addresses and zones.

So it looks like all we need to do is update $state = $this->getState($address); to be $state = $address->administrativeArea:

$state = $this->getState($address);

@imagehat
Copy link
Collaborator

imagehat commented Aug 10, 2022

Oops, I thought I caught all the address changes. You are right, thanks, I can push a fix for this later today.

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

No branches or pull requests

2 participants