2
Answers
Vote up!
0
Vote down!

How do I deal with complex discounting rules?

Hi,

I need to replicate an ordering system that fulfils the following criteria...

1. User places an order. When they hit confirm the order is emailed to me. Drupal Commerce doesn't take any payment or generate an invoice.

2. A user has one of the following roles: "Discount Band A", "Discount Band B", "Discount Band C"

Depending on their role they will get a certain discount off a product. That discount is on a per product basis.

For example I might have...

Product 1
list price: $120
A: 30%
B: 40%
C:50%

Product 2
list price: $200
A: 25%
B:15%
C: 12%

So a user with the role Discount Band A would see a price of $120 - 30% for Product 1, and $200 - 25% for Product 2.

The second problem is the more convoluted one, though I'm still worried that Drupal Commerce is going to try and force me to have a proper checkout and take a payment.

Thanks for your help,
Joe

Asked by: pfeff
on June 25, 2012

2 Answers

Vote up!
1
Vote down!

If the discount is on a per-product x per-role, I would recommend adding a field to your products for each role. That field should contain a decimal, say "0.25" to indicate that this particular role for this particular product gets 25% off.

Once that is done, you create a pricing rule per role-field that has a condition for the user to have a certain role (administrator, for example) and the product to have a certain field (administrator's discount field, for example).

So, in psuedo-code it would look like this:

if ( !empty( $product->field['custom_field'] ) AND !empty( $user->role['administrator'] )) {
  $final_price = $product->field['custom_field']['value'] x $product->price['base_value'];
}
Josh Miller
Answer by: Josh Miller
Posted: Jun 26, 2012