Sha256: 54397be9a05f456a7a9c52603c9019db9db894a20f2cf579310373938354654a

Contents?: true

Size: 560 Bytes

Versions: 110

Compression:

Stored size: 560 Bytes

Contents

require_dependency 'spree/shipping_calculator'

module Spree
  module Calculator::Shipping
    class PerItem < ShippingCalculator
      preference :amount, :decimal, default: 0
      preference :currency, :string, default: ->{ Spree::Config[:currency] }

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

      def compute_package(package)
        compute_from_quantity(package.contents.sum(&:quantity))
      end

      def compute_from_quantity(quantity)
        self.preferred_amount * quantity
      end
    end
  end
end

Version data entries

110 entries across 110 versions & 2 rubygems

Version Path
spree_core-3.2.9 app/models/spree/calculator/shipping/per_item.rb
spree_core-3.1.14 app/models/spree/calculator/shipping/per_item.rb
spree_core-3.3.6 app/models/spree/calculator/shipping/per_item.rb
spree_core-3.2.8 app/models/spree/calculator/shipping/per_item.rb
spree_core-3.1.13 app/models/spree/calculator/shipping/per_item.rb
spree_core-3.3.5 app/models/spree/calculator/shipping/per_item.rb
spree_core-3.3.4 app/models/spree/calculator/shipping/per_item.rb
spree_core-3.2.7 app/models/spree/calculator/shipping/per_item.rb
spree_core-3.1.12 app/models/spree/calculator/shipping/per_item.rb
solidus_core-1.2.3 app/models/spree/calculator/shipping/per_item.rb
solidus_core-1.1.4 app/models/spree/calculator/shipping/per_item.rb
solidus_core-1.0.7 app/models/spree/calculator/shipping/per_item.rb
spree_core-3.3.3 app/models/spree/calculator/shipping/per_item.rb
spree_core-3.2.6 app/models/spree/calculator/shipping/per_item.rb
spree_core-3.1.11 app/models/spree/calculator/shipping/per_item.rb
spree_core-3.1.10 app/models/spree/calculator/shipping/per_item.rb
spree_core-3.3.2 app/models/spree/calculator/shipping/per_item.rb
spree_core-3.2.5 app/models/spree/calculator/shipping/per_item.rb
spree_core-3.1.9 app/models/spree/calculator/shipping/per_item.rb
spree_core-3.3.1 app/models/spree/calculator/shipping/per_item.rb