Sha256: 4c87fac5303a75883242b3cca68df048494f4d652c2f031d43880e70d11de707

Contents?: true

Size: 676 Bytes

Versions: 20

Compression:

Stored size: 676 Bytes

Contents

require_dependency 'spree/shipping_calculator'

module Spree
  module Calculator::Shipping
    class PriceSack < ShippingCalculator
      preference :minimal_amount, :decimal, default: 0
      preference :normal_amount, :decimal, default: 0
      preference :discount_amount, :decimal, default: 0
      preference :currency, :string, default: ->{ Spree::Config[:currency] }

      def compute_package(package)
        compute_from_price(total(package.contents))
      end

      def compute_from_price(price)
        if price < preferred_minimal_amount
          preferred_normal_amount
        else
          preferred_discount_amount
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
solidus_core-2.4.2 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-2.3.1 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-2.4.1 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-2.2.2 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-2.1.1 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-2.4.0 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-2.4.0.rc1 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-2.4.0.beta1 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-2.3.0 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-2.3.0.rc3 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-2.3.0.rc2 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-2.3.0.rc1 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-2.3.0.beta1 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-2.2.1 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-2.2.0 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-2.2.0.rc1 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-2.2.0.beta1 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-2.1.0 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-2.1.0.rc1 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-2.1.0.beta1 app/models/spree/calculator/shipping/price_sack.rb