Skip to content

mespina/spree_weight_rates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SpreeWeightRates

Spree extension which supports sales weight based pricing.

Inspired by https://github.com/freego/spree_simple_weight_calculator

Installation

Add spree_weight_rates to your Gemfile:

gem 'spree_weight_rates'

Bundle your dependencies and run the installation generator:

bundle
bundle exec rails g spree_weight_rates:install

Usage

The new WeightRates calculator available it's based on the total weight of the package.

All configurations are described below:

Preference Type Description Default
costs_string Text Cost matrix by weight ranges 1:5\n2:7\n5:10\n10:15\n100:50
default_weight Float Default weight for product without an preset value 1 (1kg)
upcharge Float Extra cost per kilo of weight exceeds the maximum value set in costs_string 0
only_integers Boolan if set to true, the decimal figures are rounded to the upper integer true

costs_string format

You simply specify a table with weight and price splitted by : in the textarea, like this:

5.0:10
10.5:15
100.0:50.5

Each new row define a new range of values.

This means:

  • up to 5kg cost is 10

  • up to 10.5kg cost is 15

  • up to 100kg cost is 50.5

  • over 100kg use upcharge amount to calculate a price for each extra kg.

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_weight_rates/factories'

Copyright (c) 2014 Acid Labs, all rigths reserved.

About

Spree extension which supports sales weight based pricing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published