Jump to content

Can't add or change any states


Recommended Posts

  • 2 weeks later...

Temporary workaround (if you cannot upgrade immediately)

This is a known bug in PrestaShop 9.0.2, not a configuration issue.

The back office State form sends country_id as a string, but the core command expects an integer, which causes the fatal error when adding or editing states.

You can apply a temporary core patch until you upgrade.

o File to edit:
/src/Core/Form/IdentifiableObject/DataHandler/StateFormDataHandler.php

o Find the code that creates AddStateCommand (or EditStateCommand), similar to:

new AddStateCommand( $data['country_id'], $data['iso_code'], $data['name'], $data['enabled'] );

o Fix by casting country_id to int:

$countryId = (int) $data['country_id']; new AddStateCommand( $countryId, $data['iso_code'], $data['name'], $data['enabled'] );

o Clear cache after the change:
Advanced Parameters → Performance → Clear cache
(or delete /var/cache/*)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...