Created
May 24, 2012 14:34
-
-
Save mscottford/2781923 to your computer and use it in GitHub Desktop.
Spree::Order#variant should trigger update!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Subtotal: 0.0 | |
Total: 0.0 | |
Spree Bag: 22.99 | |
Subtotal: 0.0 | |
Total: 0.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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