Eric Gross
05/31/2023, 11:28 PMSpree::Order.create!(user: @contract.initiated_to_user)
product = Spree::Product.all.first
line_item = Spree::LineItem.create!(order: order, product: product, price: 100, quantity: 1)
order.next!
order.complete!
and it seems to be nondeterministic as to whether the line item's item_total_before_tax
has a value of 100
... is there a better way to create an order and add a line item, and then complete the order?
i have removed a few steps to simplify
base.remove_checkout_step :address
base.remove_checkout_step :delivery
Eric Gross
05/31/2023, 11:57 PMAdam Mueller
06/01/2023, 3:16 PMOrderContents
to add the item to the order instead of trying to create the line item directly. (https://github.com/solidusio/solidus/blob/main/core/app/models/spree/order_contents.rb) Something like:
order.contents.add(product.variants.first)
order.contents.advance # Will call next until it can't anymore.
order.complete!
Adam Mueller
06/01/2023, 3:18 PMAdam Mueller
06/01/2023, 3:20 PM