It's not possible to create a product or an order if there are no stores. The UX is weird, cause the store field repeatedly fails validation.
We should create a trait and use it in ProductForm / OrderForm, outputting a red box with a message (containing a link to the store add form, with a destination back to the current form) instead of the actual form.
Comments
Comment #2
bojanz commentedWe can place the trait in \Drupal\commerce_store\Form\StoreWarningTrait.
The order and product form would use the trait, call $this->buildStoreWarning(), and if the output is not empty, replace the form with the warning.
The buildStoreWarning() method would do an entity query to get the number of stores, if the count is 0, return the warning element.
Comment #3
harings_rob commentedI will work on this.
Comment #4
bojanz commentedI've committed an improved version of this in https://github.com/drupalcommerce/commerce/commit/e837ba054b07d5a1857924...
I ended up removing the trait and repeating the code in both forms, since it's a small amount of code reliant on external dependencies, and because I wanted different messages on the two forms.
Worth mentioning:
Turns out the current url can be received using the trick above. Didn't know that.
Also decided to hardcode the route to the add page, since it follows standards and can't change.
Comment #6
harings_rob commentedHi,
Looks better now.
It's good that I can see how you changed it. Gives me a better view on how things are done.
Regards,