cubecart / v6

CubeCart Version 6
https://cubecart.com
73 stars 57 forks source link

State Selector vs Text Entry #1197

Closed bhsmither closed 8 years ago

bhsmither commented 8 years ago

When the browser javascript has been disabled or crashed, all skins are still (mostly) fully functional. allowing the customer to be able to submit a value for State/County that is either empty or spelled incorrectly.

With regards to Issues #1080, #931, #871, and #817, suggest that server-side checking include matching the supplied State to the supplied Country. Do more than simply checking for emptiness. If the supplied State cannot be found as a known abbrev for the country_id given, then bounce with error message.

The value from the function state_json() may useful, but may need enhancing to include the abbrev as well.

With many other CC6 functions and features (module zone limits, taxation, basket contents passed to shipping, etc) relying on having the state's id, aggressively making sure that the id is available and used is important.

https://forums.cubecart.com/topic/51577-customer-able-to-bypass-state-dropdown-box-usa/

jasehead commented 8 years ago

I'd like the test to apply to existing customer states too, not just new customers. Still getting '0' as a state value on some orders from v3 customers in an upgraded v6 store.

bhsmither commented 8 years ago

Please take a look at: http://www.cubecartforums.org/index.php?showtopic=18320

This (if I recall, it is a plugin) was written for CC5, but should also work for CC6. It affects the Addressbook, not existing Orders.

bhsmither commented 8 years ago

CC6012 does have an upgrade script applied against the addressbook that is run during the upgrading process. This attempts to change abbreviations (such as IL or Wa) and full names (such as Illinois or Washington) to the state ident number.

But it will not find deviations - such as Wash.D.C, or Calif, or Ill. or all caps like IOWA.

jasehead commented 8 years ago

The upgrade script may not apply for other state abbreviations in other countries eg. Australia

bhsmither commented 8 years ago

It will work provided that the exact name or exact abbreviation can be found in CubeCart_geo_zone, such as Australian Capital Territory or ACT (as opposed to any deviation, like AusCapTer).

jasehead commented 8 years ago

No, it didn't work in more than one upgrade from v3.0.17 to v6.0.12 - I had LOTS of admin edited Australian states with 2-3 letter abbreviations that carried over into v6 OK, but in the order overview for new orders those abbreviated states were shown as a zero and the states in billing and delivery had to be reset manually.

Which is why I suggest that if an existing customer makes a new order, that the state be rechecked at that point and the State ID updated if necessary (or the existing customer asked to check and update their address).

Like you said, aggressively making sure that the ID is available and used is important - so why not error check existing addresses as well as new ones?

bhsmither commented 8 years ago

In that customer's address book, what is the Australian state that appeared as a zero in the Order Summary of a new order?

jasehead commented 8 years ago

It can be any state. I've had VIC and NSW both change to zero (and one WA for Western Australia change to Washington, which shouldn't happen).

The address from v3 gets carried across to v6 and the state remains as an abbreviation - there doesn't seem to be any mapping to state IDs for Australian states that were in v3 as standard abbreviations. The customer can place their order and the state abbreviation still appears (as a custom text value) in the order UNTIL there is an admin change to the order - like deleting credit card details for example. That is when the state gets changed to a zero value.

Sorry to drag this away from the store skin to the admin skin, but it still something that requires an error check and update for state ID - so perhaps any fix should broadly address how state ID is used throughout cubecart, from both customer and admin sides.

BTW - thank you for the CC5 plugin - hopefully that will fix any future issues.

bhsmither commented 8 years ago

There are 16 collisions in the CubeCart_geo_zone table, and the upgrade script doesn't scan that deeply to reconcile those collisions. (Hint: @abrookbanks)

abrookbanks commented 8 years ago

@bhsmither

There are 16 collisions in the CubeCart_geo_zone table, and the upgrade script doesn't scan that deeply to reconcile those collisions.

To save me time can you explain what you mean by a collision?

abrookbanks commented 8 years ago

Closed by accident! Ha. Whoops.

abrookbanks commented 8 years ago

I don't see how it is possible to make any changes here without human filtering?

bhsmither commented 8 years ago

A collision is where CubeCart_geo_zone.abbrev has the same content for more than one record.

The upgrade script /setup/scripts/upgrade/6.0.12.php deals only with the first record in the result.

The script should:

abrookbanks commented 8 years ago

Gotcha. Thanks for the clarification.