Spree Commerce

Try It Now

Volume Pricing Extension

Posted on November 26, 2008 by Sean Schofield

The Volume Pricing extension is now available in github. It uses predefined ranges of quantities to determine the price for a particular product variant. If no volume price is defined for a variant, then the standard price is used.

Each VolumePrice contains the following values:

  1. Variant: Each VolumePrice is associated with a Variant, which is used to link products to particular prices.
  2. Display: The human readable reprentation of the quantity range (Ex. 10-100). (Optional)
  3. Range: The quantity range for which the price is valid (See Below for Examples of Valid Ranges.)
  4. Amount: The price of the product if the line item quantity falls within the specified range.
  5. Position: Integer value for acts_as_list (Helps keep the volume prices in a defined order.)

Ranges

Ranges are expressed as Strings and are similar to the format of a Range object in Ruby. The lower number of the range is always inclusive. If the range is defined with ‘..’ then it also includes the upper end of the range. If the range is defined with ‘…’ then the upper end of the range is not inclusive.

Ranges can also be defined as “open ended.” Open ended
ranges are defined with an integer followed by a + character. These ranges are inclusive of the integer and any value higher than the integer.

All ranges need to be expressed as Strings and must include
parentheses. (1..10) is considered to be a valid range. 1..10 is not considered to be a valid range (missing the parens.)

Example

   Variant                Display            Range        Amount         Position<br />
   <del>-</del>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-   Rails T-Shirt          1-5                (1..5)       19.99          1<br />
   Rails T-Shirt          6-9                (6&#8230;10)     18.99          2<br />
   Rails T-Shirt          10 or more         (10+)        17.99          3

Additional Notes

The volume price is applied based on the total quantity ordered for a particular variant. It does not apply different prices for the portion of the quantity that falls within a particular range. Only the one price is used (although this would be an interesting configurable option if someone wanted to write a patch.)