9 replies [Last post]
bhallnc's picture
Offline
Joined: 03/23/2009
Juice: 81
Was this information Helpful?

Does anybody know if their is a module, besides custom price module, that will allow for tiered pricing. If there isn't, how hard would this module be to build?

A good example would be: http://www.myweddingfavors.com/champ-bucket-timer.html

I appreciate anybody's input on this.

tekad's picture
Offline
Joined: 10/21/2008
Juice: 160
Re: Tiered Pricing

I never found a module that would handle tiered pricing for me. My solution was to have set tiers and use a quantity attribute to select 20, 50, 100 products and have the price increment as part of that attribute. It was a pain in the butt since I had to have the first tier use the sell price and then subtract the original price for the first tier from all the prices of the tiers in the attribute. And this doesn't help for inventory or anything else either since the customer is basically ordering quantity 1 of "50 items."

I believe Magento does tiered pricing.

cedarm's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 08/29/2008
Juice: 100
fairly easy

I'm actually looking at custom pricing stuff myself right now. I don't know of any modules, but it shouldn't be hard. I just tried this and it seems to work just fine:

<?php
/**
* Implementation of hook_cart_item().
*
* This alters the price when the item goes into the cart.
*/
function uc_flarg_cart_item($op, &$item) {
  switch (
$op) {
    case
'load':
      if (
$item->qty >= 20) {
       
$item->price = $item->price * 0.80;
      }
      elseif (
$item->qty >= 10) {
       
$item->price = $item->price * 0.90;
      }
      elseif (
$item->qty >= 5) {
       
$item->price = $item->price * 0.95;
      }
      break;
  }
}
?>

The more difficult part will be creating the admin interfaces for changing the rules/tiers in a flexible manner.

bhallnc's picture
Offline
Joined: 03/23/2009
Juice: 81
Re: fairly easy

Would it be possible to make a module that works as seamless as magento does with tiered pricing? I need the ability to have flexibility with quantities/pricing, as the quantity requirements change with each product.

Thank you each for your input, this is definitely a great start to solving this issue for me.

cedarm's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 08/29/2008
Juice: 100
why not?

I don't see why not. I'd probably just keep it simple, unless you're willing to spend some more time on it. No need for AJAX. Add a textarea to product nodes for the prices in a minqty: price format, eg.

5: 11.99
10: 10.99
20: 8.99

This also allows convenient pasting from an email, for example. Maybe even add logic to check if the price contains % and calculate the value (don't forget to round).

Munge the string and validate any parse errors at input. Convert it to an array and serialize it. Create a database table to save this data into, then load it back when the product node loads. Then in hook_cart_item(), inspect what you loaded as $item->price_tiers or whatever you name it.

I know the textarea thing sounds ugly, but for an admin only feature I've used the concept before and it works quite well.

(BTW, if you're willing to pay a bounty, you may convince me to write this myself... Smiling

daveydo's picture
Offline
Joined: 01/05/2009
Juice: 93
This looks like just what I need . . .

but where do you put it, and where do you call it?

Is hook_cart_item something that already exists? If so, is it different in UC 2.

tia,

david

cedarm's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 08/29/2008
Juice: 100
docs/hooks.php

I keep forgetting that lots of people are in UC 1 land. I'm working solely with UC 2 on a new site, so I can't answer for UC1. Look in the UC module directory/docs/hooks.php. Or, install the api module, which makes reading code quite nice.

As for where to put it, I'm guessing you're not a module developer. In my example above, I created a module called uc_flarg and it has a function named uc_flarg_cart_item(), which is an "implementation of hook_cart_item()". Read the developer docs for more information. (Also, note that modifying code in docs/hooks.php will do nothing. It's only there as documentation.)

daveydo's picture
Offline
Joined: 01/05/2009
Juice: 93
Now this is a fantastic reply

Teach a man to fish as they say. I appreciate the helpful info.

update --- now I'm a module developer (on the practice squad anyway) I implemented this in test and now it's live. Thanks a ton.

For anyone else new to this stuff, http://drupal.org/node/508 was very helpful in addition to the links provided by cmyers above.

daveydo's picture
Offline
Joined: 01/05/2009
Juice: 93
Update

I've thrown out the custom code I did and now use this: http://drupal.org/project/uc_discounts_alt
to effectively get tiered pricing. I set up a fixed dollar amount and have it apply to a particular quantity range. To the end user it appears as a discount off the standard price, not as a reduced price. The bottom line affect is identical, if you absolutely must reflect a lower price rather than a discount for some reason, this approach will not work for you.

christopherhanson's picture
Offline
Joined: 11/10/2010
Juice: 10
Re: Tiered Pricing

this was doing my head in - had to do this for a big UK client - just finished a custom module getting this working - works great has admin backend so you select the attribute on the product you want to do tiered pricing by then can add ass many qty headers and set price per attribute option per qty header - been working on this for 2 weeks - now I just have to go through the rough code and clean the hell out of it! Laughing out loud any one need any help still with this subject give me a message - not sure if this would be worth making into a project on drupal.org?

Chris