Sha256: a70afdb294cc70fca94baf032f8466a8a6b5c02f4ef2a8e99da05b4d2a0f5fae

Contents?: true

Size: 354 Bytes

Versions: 9

Compression:

Stored size: 354 Bytes

Contents

Spree::Order.class_eval do
  def self.build_from_api(user, params)
    order = create
    params[:line_items_attributes] ||= []
    params[:line_items_attributes].each do |line_item|
      order.add_variant(Spree::Variant.find(line_item[:variant_id]), line_item[:quantity])
    end

    order.user = user
    order.email = user.email
    order
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
spree_api-1.2.5 app/models/spree/order_decorator.rb
spree_api-1.2.4 app/models/spree/order_decorator.rb
spree_api-1.2.3 app/models/spree/order_decorator.rb
spree_api-1.3.1 app/models/spree/order_decorator.rb
spree_api-1.3.0 app/models/spree/order_decorator.rb
spree_api-1.3.0.rc2 app/models/spree/order_decorator.rb
dup_spree_api-1.3.0.rc1 app/models/spree/order_decorator.rb
spree_api-1.3.0.rc1 app/models/spree/order_decorator.rb
spree_api-1.2.2 app/models/spree/order_decorator.rb