Permalink
Browse files

Update the documentation.

  • Loading branch information...
1 parent 07fe92e commit 7436dd1d8a113701a001d0e7a9359f145b01a189 Adam Wróbel committed Apr 12, 2011
Showing with 41 additions and 25 deletions.
  1. +41 −25 README.md
View
@@ -1,5 +1,4 @@
-Simple Volume Pricing
-=====================
+# Simple Volume Pricing
Simple Volume Pricing is an extension to Spree (a complete open source commerce
solution for Ruby on Rails) that allows order quantity to determine the price
for a particular product variant. For instance the variant's starting price
@@ -16,17 +15,37 @@ Each VolumePrice contains the following values:
3. **Price:** The price of the variant if the line item quantity is big enough
for this VolumePrice to apply.
-Additionally Variant objects get a new boolean property
+Variant objects get a new boolean property
`progressive_volume_discount` to select between two available discount
strategies.
+Product objects get a boolean property
+`variants_use_master_discount` that controls whether the volume is calculated
+per product or separately for each of it's variants.
+
If you want to see the extension's UI there are
[screenshots](https://github.com/amw/spree-simple-volume-pricing/wiki/Screenshots)
available.
-Uniform vs Progressive volume discount
-======================================
+# Installation
+Currently I do not release this extension as a gem. To use it add this to your
+Gemfile:
+
+ gem "spree_simple_volume_pricing", :git => "https://github.com/amw/spree-simple-volume-pricing.git", :tag => "v3.0.0"
+
+
+# Options
+
+## Single volume discount for all variants
+By default volume discount is configured and calculated separately for all
+variants. There is a per-product preference that you can use if you want it to
+be calculated based on the sum of product's variants in the cart. This implies
+that the starting price and volume prices that were set for particular variants
+will be ignored and, instead, the product's own pricing scheme will be used.
+
+
+## Uniform vs Progressive volume discount
This extension supports two discount strategies. Uniform volume discount selects
one VolumePrice based on ordered quantity and applies it to all ordered units.
Progressive volume discount applies different VolumePrices to different portions
@@ -39,8 +58,7 @@ buy X + Y units than just X (a substantial price drop can neglect an added
quantity).
-Uniform Volume Discount examples
-================================
+### Uniform Volume Discount examples
Rails T-Shirt variant has a price of $19.99. Consider the following examples of
volume prices:
@@ -49,7 +67,7 @@ volume prices:
Rails T-Shirt 5 18.00
Rails T-Shirt 20 15.00
-## Example 1
+#### Example 1
Cart Contents:
Product Quantity Price Total
@@ -60,7 +78,7 @@ Order details:
Subtotal: 19.99
-## Example 2
+#### Example 2
Cart Contents:
Product Quantity Price Total
@@ -72,7 +90,7 @@ Order details:
Volume Discount: -9.95 # 5 * (19.99 - 18.00)
Subtotal: 90.00 # 5 * 18.00
-## Example 3
+#### Example 3
Cart Contents:
Product Quantity Price Total
@@ -84,7 +102,7 @@ Order details:
Volume Discount: -11.94 # 6 * (19.99 - 18.00)
Subtotal: 108.00 # 6 * 18.00
-## Example 4
+#### Example 4
Cart Contents:
Product Quantity Price Total
@@ -97,11 +115,10 @@ Order details:
Subtotal: 300.00 # 20 * 15.00
-Progressive Volume Discount examples
-====================================
+### Progressive Volume Discount examples
Given the same volume prices configuration as in uniform discount examples.
-## Example 1
+#### Example 1
Cart Contents:
Product Quantity Price Total
@@ -113,7 +130,7 @@ Order details:
Volume Discount: -3.98
Subtotal: 115.96 # 4 * 19.99 + 2 * 18.00
-## Example 2
+#### Example 2
Cart Contents:
Product Quantity Price Total
@@ -126,8 +143,7 @@ Order details:
Subtotal: 439.96 # 4 * 19.99 + 15 * 18.00 + 6 * 15.00
-Why is it simple
-================
+# Why is it simple
This extension is called Simple to differentiate it from [another volume pricing
extension](https://github.com/railsdog/spree-volume-pricing) created and
maintained by the Spree Core team at RailsDog.
@@ -144,24 +160,25 @@ ranges. The models were unnecessarily complicated. Why `acts_as_list` if you can
just order volume prices by their lower quantity range end?
-Volume Customers
-================
+# Volume Customers
By default volume prices are calculated based only on the quantity of the
current order. But your business might want to allow customers to buy huge
volumes over a number of smaller orders. If you want to include quantities from
customer's past orders in volume price calculation you can overwrite
`Order::variant_starting_quantity(variant)` method. By default it returns 0.
-## Example
+#### Example
If you want to calculate customer's volume discount based on his order history
from last 31 days just add this to your site's code:
Order.class_eval do
- def variant_starting_quantity variant
- orders = Order.complete.by_customer(self.email).between(self.created_at - 31.days, self.created_at + 1.day)
+ def variants_starting_quantity *variant_ids
+ orders = Order.complete.by_customer(self.email).between(self.created_at - 1.month + 1.day, self.created_at + 1.day)
orders.map do |o|
- o.line_items.select {|li| li.variant_id == variant.id}.map(&:quantity).sum
+ o.line_items.select do |li|
+ variant_ids.include? li.variant_id
+ end.map(&:quantity).sum
end.sum
end
end
@@ -191,8 +208,7 @@ Order details:
Subtotal: 72.00 # 4 * 18.00
-Authors
-=======
+# Authors
This extension is based on
[spree-volume-pricing](https://github.com/railsdog/spree-volume-pricing)
extension. It was rewritten by Adam Wróbel of Flux Inc, but there are some bits

0 comments on commit 7436dd1

Please sign in to comment.