Skip to content

Instantly share code, notes, and snippets.

@mscottford
Created May 24, 2012 14:34
Show Gist options
  • Save mscottford/2781923 to your computer and use it in GitHub Desktop.
Save mscottford/2781923 to your computer and use it in GitHub Desktop.
Spree::Order#variant should trigger update!
Subtotal: 0.0
Total: 0.0
Spree Bag: 22.99
Subtotal: 0.0
Total: 0.0
def totals(order)
order.line_items.each do |item|
puts "#{item.variant.name}: #{item.amount}"
end
puts "Subtotal: #{order.item_total}"
puts "Total: #{order.total}"
end
order = Spree::Order.create!
totals(order)
puts
order.add_variant(Spree::Variant.find_by_sku('SPR-00012'))
totals(order)
puts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment