Class: SpreeCmCommissioner::PricingModelHandler::Order
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::PricingModelHandler::Order
- Defined in:
- app/models/spree_cm_commissioner/pricing_model_handler/order.rb
Overview
Handles pricing model activation for orders
Instance Attribute Summary collapse
-
#order ⇒ Object
readonly
Returns the value of attribute order.
Instance Method Summary collapse
- #activate ⇒ Object
-
#initialize(order) ⇒ Order
constructor
A new instance of Order.
Constructor Details
#initialize(order) ⇒ Order
Returns a new instance of Order.
7 8 9 |
# File 'app/models/spree_cm_commissioner/pricing_model_handler/order.rb', line 7 def initialize(order) @order = order end |
Instance Attribute Details
#order ⇒ Object (readonly)
Returns the value of attribute order.
5 6 7 |
# File 'app/models/spree_cm_commissioner/pricing_model_handler/order.rb', line 5 def order @order end |
Instance Method Details
#activate ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/models/spree_cm_commissioner/pricing_model_handler/order.rb', line 11 def activate return unless order&.persisted? order.adjustments.pricing_action.delete_all order.line_items.each { |li| li.adjustments.pricing_action.delete_all } order.connected_line_item_ids.each do |group_ids| line_items_in_group = order.line_items.where(id: group_ids) activate_for_line_items(line_items_in_group) end end |