Spree extension which supports sales weight based pricing

Last updated on: October 23 at 02:41 PM

source code bug tracker
1 1 2
owner:  mespina


Spree 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 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

costs_string format

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


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.


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

compatible spree versions
tags spree versions
master ~> 2.3.1
Marcelo Espina