Sha256: b59188625a4132546acb181a5cef9dda3c859100fa392aa1c058f5b96ce0756e

Contents?: true

Size: 720 Bytes

Versions: 62

Compression:

Stored size: 720 Bytes

Contents

module Workarea
  class OrderMerge
    attr_reader :original

    def initialize(original)
      @original = original
    end

    def merge(other)
      return unless original.valid?

      other.items.each do |item|
        next if original.has_sku?(item.sku)

        attributes = OrderItemDetails.find!(item.sku, product_id: item.product_id).to_h

        original.add_item(
          attributes.merge(
            product_id: item.product_id,
            sku: item.sku,
            quantity: item.quantity,
            customizations: item.customizations
          )
        )
      end

      other.promo_codes.each do |code|
        original.add_promo_code(code)
      end

      original.save!
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.5.15 app/services/workarea/order_merge.rb
workarea-core-3.4.36 app/services/workarea/order_merge.rb
workarea-core-3.5.14 app/services/workarea/order_merge.rb
workarea-core-3.4.35 app/services/workarea/order_merge.rb
workarea-core-3.5.13 app/services/workarea/order_merge.rb
workarea-core-3.4.34 app/services/workarea/order_merge.rb
workarea-core-3.5.12 app/services/workarea/order_merge.rb
workarea-core-3.4.33 app/services/workarea/order_merge.rb
workarea-core-3.5.11 app/services/workarea/order_merge.rb
workarea-core-3.5.10 app/services/workarea/order_merge.rb
workarea-core-3.4.32 app/services/workarea/order_merge.rb
workarea-core-3.5.9 app/services/workarea/order_merge.rb
workarea-core-3.4.31 app/services/workarea/order_merge.rb
workarea-core-3.5.8 app/services/workarea/order_merge.rb
workarea-core-3.4.30 app/services/workarea/order_merge.rb
workarea-core-3.5.7 app/services/workarea/order_merge.rb
workarea-core-3.4.29 app/services/workarea/order_merge.rb
workarea-core-3.5.6 app/services/workarea/order_merge.rb
workarea-core-3.4.28 app/services/workarea/order_merge.rb
workarea-core-3.5.5 app/services/workarea/order_merge.rb