Git Product home page Git Product logo

spree-price-bucket-shipping-calculator's Introduction

Price Bucket Shipping Rate

Supports Spree >= 0.8.x

The Price Bucket Shipping Rate Calculator allows you to define shipping costs based on the order's sub-total and shipping method.

When installed, a new "Price Bucket Shipping Rates" link is added to the Configuration area in the Spree administration interface. Here you can define as many different rates as required, and link them to the relevant Shipping Methods

Each PriceBucketShippingRate contains the following values:

  1. Shipping Method: Each PriceBucketShippingRate is associated with a Shipping Method, which is used to link products to particular rates.

  2. Price Floor: This is the lower end of the price range for defining the "price bucket". The value is inclusive.

  3. Price Ceiling: This is the upper end of the price range for defining the "price bucket" The value is inclusive.

  4. Shipping Rate: Is the shipping charge to apply to the order for order's whose sub-totals fall within this price bucket.

Examples

The sample data contained with this extension shows how to configure Spree to support multiple PriceBucketShippingRates broken down by three different Shipping Methods.

   Shipping Method              Price Floor       Price Ceiling        Shipping Rate               -------------------------------------------------------------------------------------------
   Standard Shipping            $   0.00           $  15.00             $  4.00
   Standard Shipping            $  15.01           $  35.00             $  8.00
   Standard Shipping            $  35.01           $ 100.00             $ 16.00
   Standard Shipping            $ 100.01           $ 999.00             $  0.00

   Express Shipping             $  0.00            $  15.00             $  8.00
   Express Shipping             $ 15.01            $  35.00             $ 16.00
   Express Shipping             $ 35.01            $ 999.00             $ 32.00
   Express Shipping            $ 100.01            $ 999.00             $ 16.00

Quick Start

  1. Install extension:

    script/extension install git://github.com/mwlang/spree-price-bucket-shipping-rate.git

  2. Migrate the database (or bootstrap if you want the sample data for testing)

    rake db:migrate

spree-price-bucket-shipping-calculator's People

Stargazers

Michael Powell avatar G. Gibson avatar Austin Strange avatar Ben van de Sande avatar Marcin Raczkowski avatar Michael Lang avatar Jindong Yang avatar Jorge Calás avatar

Watchers

Michael Lang avatar James Cloos avatar  avatar  avatar

spree-price-bucket-shipping-calculator's Issues

some issues with new edge version

seems like the new version of spree has reworked the way calculators work, hence price-bucket does not work anymore. I just got it to work by making the following changes:

  1. remove lib/spree/price_bucket_shipping_calculator/calculator.rb

  2. add modified calculator to: app/models/price_bucket_shipping_calculator.rb with the following:

    class PriceBucketShippingRateCalculator < ShippingCalculator
    def calculate_shipping(shipment)
    item_total = shipment.order.item_total
    shipping_method = calculable
    PriceBucketShippingRate.get_shipping_rate(item_total, shipping_method)
    end
    end

Basically, the idea is to make the calculator a subclass of ShippingCalculator and since shipping_method in shipment during calculate_shipping is undefined until after the order is completed, we use calculator.calculable to reference it.

EDIT: Also need to add the following to your extension in order to make the calculator available when creating shipping methods:

Admin::ShippingMethodsController.class_eval do
    private
    def load_data
      @available_zones = Zone.find :all, :order => :name
      @shipping_calculators = [PriceBucketShippingRateCalculator, FlatRateShippingCalculator]
    end
end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.