1
Answers
Role based product variations
I have products with multiple variations. How can I control which variations users can see and choose based on their role?
I have products with multiple variations. How can I control which variations users can see and choose based on their role?
One possible idea could be:
- Add a "role_field" to the Product Variation Type
- Implement hook_entity_view_alter (viewing products list) and hook_form_alter (altering the add_to_cart form)
Not really sure if that's the best approach.
You could also play with Views and Access Control by role, but in that case you would (possibly) need a Product Variation Type per role, for easy view creation/filtering.
By clicking any link on this page you are giving your consent for us to set cookies.
Comments
Thanks favrik,
I've tried Access Control, but it only works with nodes (Product Displays), and with Product Variations being a part of Commerce I would need something on an Entity level. I've also tried Taxonomy Access Control module hoping to restrict access to a term referencing an attribute, but it also was a no go. I'm not that good with hooks yet, but I'll look into it. Any other suggestions are welcome.