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.
I have given enough permissions for a authenticated user to be able to access "admin/commerce/stores/add/store" and create a new store.
I would want to try and restrict only one store per user. I know that now is working as designed so I'm just asking for a little guidance on where I should look to make it custom for my use-case.
In my case a user would be able to create one store, and when is creating a product , his store would be "pre-selected" as the store for that product. I thought that "Entityreference prepopulate" could be of help here..
Thanks
Comments
Comment #1
maciej.zgadzaj CreditAttribution: maciej.zgadzaj commentedI guess for the moment the easiest way would be to override stores/add access callback to your own custom function, which would check both existing access rights and additionally verify whether user already has a store created.
I have a feeling there might be more people interested in such a feature, so I might add it to the module at one point...
Comment #2
cornelyus CreditAttribution: cornelyus commentedThanks!
Comment #3
cornelyus CreditAttribution: cornelyus commentedQuick question.
I was able to implement this, seems to be working fine.
On another note, my authenticated users can create stores by themselves. But, choosing the enabled payments is not appearing on the form.
Am I missing something?
Comment #4
maciej.zgadzaj CreditAttribution: maciej.zgadzaj commentedMind sharing the code?
This should be fixed in Access to options and payment methods vertical tabs for new stores.
Comment #5
cornelyus CreditAttribution: cornelyus commentedNot at all, but maybe this would only work for my case? Never contributed to modules before..
So, I changed the 'access callback' for the menu link to create stores , as found on commerce_store_ui.module file.
On my new access function
Hope this is helpful for now.
Comment #6
fehin CreditAttribution: fehin commentedThank you for this great module!
I'm wondering if there is any progress on this. Merchants are only allowed to have one store on my website but they can create many at the moment.
Comment #7
fehin CreditAttribution: fehin commentedI got around it by creating a rule. Whenever a user becomes a Merchant and isn't currently in ex-merchant role (to prevent two stores if old one wasn't deleted), a store is created for them. Now I just need to remove the add store link and filter store form in the body of the stores page.
Comment #8
shasha_s CreditAttribution: shasha_s commentedHello,
thank you for this nice module.
Can you please share, explain how you realized it with rules?
Thanks!
Comment #9
fehin CreditAttribution: fehin commented@shasha_s below is a copy of my rule. Like I said, I created another role called ex-merchant so you need to create one.
Also find the id of your roles and replace them in the rule before you import it.
Comment #10
shasha_s CreditAttribution: shasha_s commentedfehin,thanks for your response.
I will check it out and will report
Comment #11
hedel CreditAttribution: hedel commentedI did something similar using Profile2, I let the rule here and I'm listening ideas ...
(Adapt to your profiles and roles)