Sha256: 82993489b923c147de8feec6d7f980ecfba44893224ba495f8a4b830f962a267

Contents?: true

Size: 512 Bytes

Versions: 28

Compression:

Stored size: 512 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)
        content_items = package.contents
        self.preferred_amount * content_items.sum { |item| item.quantity }
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
spree_core-2.2.14 app/models/spree/calculator/shipping/per_item.rb
spree_core-2.2.13 app/models/spree/calculator/shipping/per_item.rb
spree_core-2.2.12 app/models/spree/calculator/shipping/per_item.rb
spree_core-2.2.11 app/models/spree/calculator/shipping/per_item.rb
spree_core-2.2.10 app/models/spree/calculator/shipping/per_item.rb
spree_core-2.2.9 app/models/spree/calculator/shipping/per_item.rb
spree_core-2.1.12 app/models/spree/calculator/shipping/per_item.rb
spree_core-2.2.8 app/models/spree/calculator/shipping/per_item.rb
spree_core-2.1.11 app/models/spree/calculator/shipping/per_item.rb
spree_core-2.2.7 app/models/spree/calculator/shipping/per_item.rb
spree_core-2.1.10 app/models/spree/calculator/shipping/per_item.rb
spree_core-2.1.9 app/models/spree/calculator/shipping/per_item.rb
spree_core-2.2.6 app/models/spree/calculator/shipping/per_item.rb
spree_core-2.2.5 app/models/spree/calculator/shipping/per_item.rb
spree_core-2.1.8 app/models/spree/calculator/shipping/per_item.rb
spree_core-2.2.4 app/models/spree/calculator/shipping/per_item.rb
spree_core-2.2.3 app/models/spree/calculator/shipping/per_item.rb
spree_core-2.2.2 app/models/spree/calculator/shipping/per_item.rb
spree_core-2.1.7 app/models/spree/calculator/shipping/per_item.rb
spree_core-2.1.6 app/models/spree/calculator/shipping/per_item.rb