Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem
After a fresh commerce install I went to /product/add/default where I can see the following text:
Products can't be created until a store has been added. Add a new store.
"Add a new store" links to "/store/add?destination=/product/add/default". Since however I only have the 'default' store type the "/store/add" page tries to redirect me to "/store/add/default" but it can't because of the destination query. So I end up on the same "/product/add/default" page.
Proposed resolution
Check the number of store entity types and link to "/store/add/[store-entity-type]?destination=/product/add/default" if there's only one.
Comments
Comment #2
harings_rob CreditAttribution: harings_rob at Harings.be commentedComment #3
harings_rob CreditAttribution: harings_rob at Harings.be commentedPR: https://github.com/drupalcommerce/commerce/pull/350
I have added a helper function as we need this link on multiple places.
Now it will send you to the add_form directly if there is one store type, in other cases it will send you to the add_page.
Comment #4
harings_rob CreditAttribution: harings_rob at Harings.be commentedComment #5
harings_rob CreditAttribution: harings_rob at Harings.be commentedNow that I see https://github.com/drupalcommerce/commerce/pull/347, we might want to create a helper class for this sort of functions in commerce_order as wel?
Comment #6
bojanz CreditAttribution: bojanz at Centarro commentedComment #8
bojanz CreditAttribution: bojanz at Centarro commentedWe ended up removing ?destination cause there's no way to make it work well (if you go to add-page to select a bundle, then that link loses ?destination)
Committed, thanks!
EDIT: D'oh, forgot to give commit credit. I'll make up for it in another commit :)