Sha256: 2cb4082d5283cea92cda74262dc99bc081d9860db8239c969721b0c4cdb3405f

Contents?: true

Size: 1.09 KB

Versions: 42

Compression:

Stored size: 1.09 KB

Contents

Spree::Sample.load_sample('addresses')

orders = []
orders << Spree::Order.where(
  number: 'R123456789',
  email: 'spree@example.com'
).first_or_create! do |order|
  order.item_total = 150.95
  order.adjustment_total = 150.95
  order.total = 301.90
end

orders << Spree::Order.where(
  number: 'R987654321',
  email: 'spree@example.com'
).first_or_create! do |order|
  order.item_total = 15.95
  order.adjustment_total = 15.95
  order.total = 31.90
  order.shipping_address = Spree::Address.first
  order.billing_address = Spree::Address.last
end

unless orders[0].line_items.any?
  orders[0].line_items.new(
    variant: Spree::Product.find_by!(name: 'Ruby on Rails Tote').master,
    quantity: 1,
    price: 15.99
  ).save!
end

unless orders[1].line_items.any?
  orders[1].line_items.new(
    variant: Spree::Product.find_by!(name: 'Ruby on Rails Bag').master,
    quantity: 1,
    price: 22.99
  ).save!
end

orders.each(&:create_proposed_shipments)

store = Spree::Store.default

orders.each do |order|
  order.state = 'complete'
  order.store = store
  order.completed_at = Time.current - 1.day
  order.save!
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
spree_sample-4.0.9 db/samples/orders.rb
spree_sample-4.0.8 db/samples/orders.rb
spree_sample-3.7.14.1 db/samples/orders.rb
spree_sample-4.0.7.1 db/samples/orders.rb
spree_sample-4.0.7 db/samples/orders.rb
spree_sample-3.7.14 db/samples/orders.rb
spree_sample-4.0.6 db/samples/orders.rb
spree_sample-3.7.13 db/samples/orders.rb
spree_sample-4.0.5 db/samples/orders.rb
spree_sample-3.7.12 db/samples/orders.rb
spree_sample-4.0.4 db/samples/orders.rb
spree_sample-3.7.11 db/samples/orders.rb
spree_sample-3.7.10 db/samples/orders.rb
spree_sample-4.0.3 db/samples/orders.rb
spree_sample-3.7.9 db/samples/orders.rb
spree_sample-4.0.2 db/samples/orders.rb
spree_sample-3.7.8 db/samples/orders.rb
spree_sample-4.0.1 db/samples/orders.rb
spree_sample-3.7.7 db/samples/orders.rb
spree_sample-4.0.0 db/samples/orders.rb