Class: Spree::OrderMerger
- Inherits:
-
Object
- Object
- Spree::OrderMerger
- Defined in:
- app/models/spree/order_merger.rb
Instance Attribute Summary collapse
-
#order ⇒ Object
Returns the value of attribute order.
Instance Method Summary collapse
-
#initialize(order) ⇒ OrderMerger
constructor
A new instance of OrderMerger.
- #merge!(other_order, user = nil, discard_merged: true) ⇒ Object
Constructor Details
#initialize(order) ⇒ OrderMerger
Returns a new instance of OrderMerger.
6 7 8 |
# File 'app/models/spree/order_merger.rb', line 6 def initialize(order) @order = order end |
Instance Attribute Details
#order ⇒ Object
Returns the value of attribute order.
3 4 5 |
# File 'app/models/spree/order_merger.rb', line 3 def order @order end |
Instance Method Details
#merge!(other_order, user = nil, discard_merged: true) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/models/spree/order_merger.rb', line 10 def merge!(other_order, user = nil, discard_merged: true) handle_gift_card(other_order) other_order.line_items.each do |other_order_line_item| next unless other_order_line_item.currency == order.currency current_line_item = find_matching_line_item(other_order_line_item) handle_merge(current_line_item, other_order_line_item) end set_user(user) clear_addresses(other_order) if discard_merged persist_merge if discard_merged # So that the destroy doesn't take out line items which may have been re-assigned other_order.line_items.reload other_order.destroy end end |