craftcms / spoke-and-chain

Craft CMS + Craft Commerce demo site.
https://craftcms.com/demo?kind=spokeandchain
BSD Zero Clause License
54 stars 28 forks source link

Unable to save store form information #123

Closed danjrichardson closed 2 years ago

danjrichardson commented 2 years ago

Description

When saving store information (admin/commerce/store-settings/store) the validation fails and you cannot save the form. This is due to the event rules in the modules\Module.php requiring firstName and lastName. Commenting out the lines in the module and then re-saving works fine. https://github.com/craftcms/spoke-and-chain/blob/stable/modules/Module.php#L59-L60

I've not looked into it too much but could checking $isStoreLocation work to conditionally add the additional firstName and lastName fields? https://github.com/craftcms/commerce/blob/356cf132f1af6dea795bdf2c42b78dfeabe59954/src/models/Address.php#L55

Steps to reproduce

  1. Log into a new installation of Spoke and Chain
  2. Navigate to Commerce -> Store Settings -> Store
  3. Click on the default "STORE"
  4. Click on "Save" on the editor slideout UI

Additional info

nfourtythree commented 2 years ago

This is now fixed on stable.

Thanks!

danjrichardson commented 2 years ago

Thanks.

Just a thought though, should address validation still be considered for a cp request? With editable orders there is an edge case there to accidentally nuke address information which the validation would otherwise pick up.

I think it's easily possible to go overkill here to fix this and start making it a "feature", but thought it worth a mention as it's sometimes easy to forget that regressions can easily be introduced in situations like this.

nfourtythree commented 2 years ago

Hi @danjrichardson

Thank you for your reply.

Certainly in a real world project that could be the case. But, as you mentioned, we don't want to over-engineer this for the demo.

We can look at this as that the editors in the admin are under less restrictions than front end customers.

Happy to take a PR if you feel like you have an ideal solution here 🙂

Thanks!