Spree extension which supports sales weight based pricing
Last updated on: October 23 at 02:41 PM
source code bug trackerSpree extension which supports sales weight based pricing.
Inspired by https://github.com/freego/spree_simple_weight_calculator
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
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 |
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:
5kg cost is 1010.5kg cost is 15up to 100kg cost is 50.5
over 100kg use upcharge amount to calculate a price for each extra kg.
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.