Different prices per role: How much work will that be?

Events happening in the community are now at Drupal community events on www.drupal.org.
kulvik's picture

Hi Everyone.

I'm developing a new e-commerce site and need to be able to specify different product prices based on role. I haven't found any info on this (except for a similar forum request from 2005).

This is my case:
This shop will sell car parts. Regular end-customers get the retail price. Workshop customers get a discount that vary for each product (so I can't just specify a discount in percent for the entire workshop). Also, large workshops can get better discounts than the small ones, so often I will have to create a role for every big workshop. This means that I can have x-number of roles with different prices.

What I need is a module that give me the following functionality:

  • Make it possible to specify (in a database table) specific prices per role for a product.
  • When a customer adds the product to cart and do the checkout, the product price will be the lowest possible price based on which roles the customer are related to.
  • When editing a product the admin can specify a product price for each role. (This form functionality isn't the most important for me right now, because all products and prices are currently imported from a CSV file.)

I know my way around PHP and have created some small modules for drupal, but to be able to develop this module I would surely need some input from you guys. What would be the best way to do this? How do I make this work in the best possible way with th rest of the e-commerce package?

Any comments are appreciated :)

-Thomas-

Comments

This has already been

gordon's picture

This has already been created, see the role_discount module which comes with E-Commerce.

--
Gordon Heydon

lol. good thing I didn't

kulvik's picture

lol. good thing I didn't start making the module then. I'll check it out.

-Thomas-

Not exactly

kulvik's picture

Hi again.

Well, that wasn't exactly what I was asking for. In fact, it was exactly what I didnt need :)

A discount per role store-wide for all products isn't what I need. What I need is a way to give a unique discount per product (for the different roles).

Any comments, insights, hints?

flexicharge

sime's picture

Heya, I always go on about Flexicharge. But this is definitely another example of how Flexicharge can help.

Flexicharge would allow you to define a charge provider (simple .inc file) that:
-- inserts a custom field into the product form (well in v4 it will)
-- allows you to process this value in the checkout
-- and label this value on the review page.

I personally think this is your best solution, but won't be ready for the custom field part until v4, so it might not suit your timeline.

.s

Thanks for the reply. I'm

kulvik's picture

Thanks for the reply. I'm afraid that I need this a bit sooner than v4. So I guess i'll have to make my own module for this.

Appreciate any help I can get on this one. I'm pretty much starting from scratch here:

  • What hooks do I have to use to be able to alter the product form?
  • In what hook should I put the code that actually alter the price during checkout and product view?
  • Is it possible to do this without altering anything in the EC package or do I have to start "messing up" the EC code? (I'd really like to keep a decent upgrade path).

Any thoughts are greatly appreciated.

-Thomas-

way forward

sime's picture

No, you don't need to mess with ec. I would still use flexicharge as a model, here is the version which is what will more or less go into v4: Flexicharge for v4
flexicharge_form_alter() is the part that allows additional fields on the product. Set up your .inc with a hook_flexicharge_attributes function to return the required attributes.
Use simple.inc to understand the other logic required in a charge provider.

So, most of the code is done, it's just that these features got bumped to v4. If you follow this path, you have a great chance of merging back with Flexicharge later. Either way, the logic is all there to achieve your goal.

Good luck!

Hi there, I am looking for

krunar's picture

Hi there,

I am looking for exactly the same feature with Kulvik and since this post is almost 1 year old i was wondering if any of you gurus has figure out a solution or if there is any module out there that offers that and i have miss it?

is it possible to achieve this result using the sub products (and restrict access to certain subproducts per user role)?

Anyway..any hit will be most appreciated.

Thank you

I am looking for the same

tomsm's picture

I am looking for the same thing.
I want to create multiple roles: retail client, reseller and export client.
The price of the product depends on the role.
So no discount, just a fixed price depeding on the role of the visitor.

Is this possible with ec4?

e-Commerce Module

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: