Sha256: a8fb616d27e11eab45769e1e9c13aabdbbc9d5a2c0f3884ec3e1ba01a1d4cd3a

Contents?: true

Size: 580 Bytes

Versions: 2

Compression:

Stored size: 580 Bytes

Contents

module Spree
  module SpreeRepeatedOrder
    module ControllerHelpers
      module RepeatedOrder

        def duplicate_order(past_order, new_order)
          new_line_items = []
          past_order.line_items.each do |line_item|
            if (line_item.product && line_item.product.available? && !line_item.product.deleted?)
              new_line_item = line_item.dup
              new_line_item.reload_price
              new_line_items << new_line_item
            end
          end

          new_order.line_items = new_line_items
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_repeat_order-2.2.1 lib/spree/spree_repeated_order/controller_helpers/repeated_order.rb
spree_repeat_order-2.1.9 lib/spree/spree_repeated_order/controller_helpers/repeated_order.rb