Code Monkey home page Code Monkey logo

spree_volume_pricing's Introduction

Volume Pricing

Build Status

Volume Pricing is an extension to Spree (a complete open source commerce solution for Ruby on Rails) that uses predefined ranges of quantities to determine the price for a particular product variant. For instance, this allows you to set a price for quantities between 1-10, another price for quantities between (10-100) and another for quantities of 100 or more. 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. Name: 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.)

Install

The extension contains a rails generator that will add the necessary migrations and give you the option to run the migrations, or run them later, perhaps after installing other extensions. The version of the extension used should match the version of Spree being used in accordance with that listed in the Versionfile. Once you have bundled the extension, run the install generator and its ready to use.

  rails generate spree_volume_pricing:install

Easily add volume pricing display to your product page:

  <%= render :partial => 'spree/products/volume_pricing', :locals => { :product => @product } %>

Ranges

Ranges are expressed as Strings and are similar to the format of a Range object in Ruby. The lower numeber 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 then 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 parentheses.)

Examples

Consider the following examples of volume prices:

   Variant                Name               Range        Amount         Position
   -------------------------------------------------------------------------------
   Rails T-Shirt          1-5                (1..5)       19.99          1
   Rails T-Shirt          6-9                (6...10)     18.99          2
   Rails T-Shirt          10 or more         (10+)        17.99          3

Example 1

Cart Contents:

   Product                Quantity       Price       Total
   ----------------------------------------------------------------
   Rails T-Shirt          1              19.99       19.99

Example 2

Cart Contents:

   Product                Quantity       Price       Total
   ----------------------------------------------------------------
   Rails T-Shirt          5              19.99       99.95

Example 3

Cart Contents:

  Product                Quantity       Price       Total
  ----------------------------------------------------------------
  Rails T-Shirt          6              18.99       113.94

Example 4

Cart Contents:

  Product                Quantity       Price       Total
  ----------------------------------------------------------------
  Rails T-Shirt          10             17.99       179.90

Example 5

Cart Contents:

  Product                Quantity       Price       Total
  ----------------------------------------------------------------
  Rails T-Shirt          20             17.99       359.80

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.)

Development

This extension uses the testing support from spree core. Once you have installed the bundle you will be able to create the test app and run the rake tests. The factories from spree/core are available within the tests.

  bundle install
  rake test_app
  rake

spree_volume_pricing's People

Contributors

bdq avatar cluster444 avatar drefined avatar jeffschuil avatar jsqu99 avatar paulsponagl avatar radar avatar romul avatar schof avatar scudco avatar timothyjoh avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.