Sha256: 5984340d4457590c5f2761c1e841401b9d7998399401cf7082462ea0bfcec14e

Contents?: true

Size: 745 Bytes

Versions: 133

Compression:

Stored size: 745 Bytes

Contents

# frozen_string_literal: true

require_dependency 'spree/calculator'
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

133 entries across 133 versions & 2 rubygems

Version Path
solidus_core-4.4.2 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-4.4.1 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-4.4.0 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-4.3.4 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-4.2.4 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-4.1.5 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-4.3.3 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-4.3.2 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-4.1.4 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-4.3.1 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-4.3.0 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-4.2.3 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-4.1.3 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-4.0.4 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-3.4.6 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-4.0.3 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-4.1.2 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-4.2.2 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-3.4.5 app/models/spree/calculator/shipping/price_sack.rb
solidus_core-4.2.1 app/models/spree/calculator/shipping/price_sack.rb