roxxypoxxy February 2016

Can I have two different kinds of user in spree?

I need to build an e-store. I am thinking of using spree gem instead of building everything from scratch but I have not used spree before. One of my requirements is to have two kinds of user and app should be able to show and apply prices based on that user. For eg. if a user is a wholesale buyer app should display lower price and if user is normal user it should show different price. Can this be readily done in spree?

Answers


apod February 2016

I worked on a project that used Spree and required extensive customization. Spree allows you to customize almost anything, though some customization is harder than others.

Spree does allow you to have multiple types of users quite easily. In fact, it doesn't assume much of anything about your user model. You can use the Devise gem or create your own user model. In either case, let's say you add a boolean called is_wholesale to your user model. Alternatively, you could use Spree's built-in roles functionality (see this link for more information).

The trickier part of your question is how exactly wholesale pricing works. If wholesale buyers get a fixed percentage discount off of retail prices (e.g., 20% off each item), then implementing this feature with Spree is quite easy. Just create a custom promotion (see this guide) with a fixed discount percentage and only make it available to your users with the is_wholesale boolean or correct Spree role. You could also customize the Spree product and category views to show the discounted price to wholesale buyers.

That said, if you want each product to truly have two prices (not just a fixed discount percentage), things get a lot more complicated. My experience (though of course I haven't tried it), is that would require mucking around with a lot of different Spree internals (e.g., the Spree product model, cart items, admin interface) and will lead to a lot of hair-pulling.

Post Status

Asked in February 2016
Viewed 3,072 times
Voted 12
Answered 1 times

Search




Leave an answer