Sha256: dbb018097d868b9414a4897538fa66c5d6e2a9c32ca315d72cc769ebb2ae9f01

Contents?: true

Size: 725 Bytes

Versions: 23

Compression:

Stored size: 725 Bytes

Contents

module Spree
  module Stock
    class InventoryUnitBuilder
      def initialize(order)
        @order = order
      end

      def units
        @order.line_items.flat_map do |line_item|
          line_item.quantity.times.map do |i|
            @order.inventory_units.includes(
              variant: {
                product: {
                  shipping_category: {
                    shipping_methods: [:calculator, { zones: :zone_members }]
                  }
                }
              }
            ).build(
              pending: true,
              variant: line_item.variant,
              line_item: line_item,
              order: @order
            )
          end
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
spree_core-2.4.4 app/models/spree/stock/inventory_unit_builder.rb
spree_core-3.0.0.rc1 app/models/spree/stock/inventory_unit_builder.rb
spree_core-2.4.3 app/models/spree/stock/inventory_unit_builder.rb