Skip to content

Spree extension that supports discounts that apply to the second unit of the same product.

License

Notifications You must be signed in to change notification settings

mespina/spree_second_units

Repository files navigation

SpreeSecondUnits

Spree extension that supports discounts that apply to units of the same product, enabling a new promotion actions calculator.

SecondUnits calculator

This calculator has two preference: percent and units, and can be set like this:

calculator.preferred_percent = 10
calculator.preferred_units   = 2

This calculator takes a LineItem and calculates an amount using this calculation:

[item price] x [percent] x [number of units with discount]

For example, if the calculator was configured to have 50 percent off over second unit (preferred_units=2) and the product has a price of $15.0

Nº Items of same product Formule Discount
1 15.0 x 0.5 x 0 $0,0
2 15.0 x 0.5 x 1 $7,5
3 15.0 x 0.5 x 1 $7,5
4 15.0 x 0.5 x 2 $15,0
5 15.0 x 0.5 x 2 $15,0
6 15.0 x 0.5 x 3 $22,5
17 15.0 x 0.5 x 8 $60,0

Installation

Add spree_second_units to your Gemfile:

gem 'spree_second_units'

Bundle your dependencies and run the installation generator:

bundle
bundle exec rails g spree_second_units:install

Testing

First bundle your dependencies, then run rake. rake will default to building the dummy app if it does not exist, then it will run specs. The dummy app can be regenerated by using rake test_app.

bundle
bundle exec rake

When testing your applications integration with this extension you may use it's factories. Simply add this require statement to your spec_helper:

require 'spree_second_units/factories'

Copyright (c) 2015 Acid Labs, released under the New BSD License

About

Spree extension that supports discounts that apply to the second unit of the same product.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published