Sha256: 85b095a939a0be32f247916fbbe456f80abd027346e45dc63f59455a01833602

Contents?: true

Size: 766 Bytes

Versions: 26

Compression:

Stored size: 766 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::Store.default.default_currency }

      def self.description
        Spree.t(:shipping_price_sack)
      end

      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

26 entries across 26 versions & 1 rubygems

Version Path
spree_core-4.10.1 app/models/spree/calculator/shipping/price_sack.rb
spree_core-4.10.0 app/models/spree/calculator/shipping/price_sack.rb
spree_core-4.9.0 app/models/spree/calculator/shipping/price_sack.rb
spree_core-4.8.3 app/models/spree/calculator/shipping/price_sack.rb
spree_core-4.8.2 app/models/spree/calculator/shipping/price_sack.rb
spree_core-4.7.3 app/models/spree/calculator/shipping/price_sack.rb
spree_core-4.6.6 app/models/spree/calculator/shipping/price_sack.rb
spree_core-4.5.5 app/models/spree/calculator/shipping/price_sack.rb
spree_core-4.4.1 app/models/spree/calculator/shipping/price_sack.rb
spree_core-4.5.4 app/models/spree/calculator/shipping/price_sack.rb
spree_core-4.6.5 app/models/spree/calculator/shipping/price_sack.rb
spree_core-4.7.2 app/models/spree/calculator/shipping/price_sack.rb
spree_core-4.7.1 app/models/spree/calculator/shipping/price_sack.rb
spree_core-4.6.4 app/models/spree/calculator/shipping/price_sack.rb
spree_core-4.7.0 app/models/spree/calculator/shipping/price_sack.rb
spree_core-4.6.3 app/models/spree/calculator/shipping/price_sack.rb
spree_core-4.6.2 app/models/spree/calculator/shipping/price_sack.rb
spree_core-4.6.1 app/models/spree/calculator/shipping/price_sack.rb
spree_core-4.6.0 app/models/spree/calculator/shipping/price_sack.rb
spree_core-4.5.3 app/models/spree/calculator/shipping/price_sack.rb