Class: SolidusPromotions::OrderAdjuster::DiscountOrder
- Inherits:
-
Object
- Object
- SolidusPromotions::OrderAdjuster::DiscountOrder
- Defined in:
- app/models/solidus_promotions/order_adjuster/discount_order.rb
Instance Attribute Summary collapse
-
#dry_run ⇒ Object
readonly
Returns the value of attribute dry_run.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#promotions ⇒ Object
readonly
Returns the value of attribute promotions.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(order, promotions, dry_run: false) ⇒ DiscountOrder
constructor
A new instance of DiscountOrder.
Constructor Details
#initialize(order, promotions, dry_run: false) ⇒ DiscountOrder
Returns a new instance of DiscountOrder.
8 9 10 11 12 |
# File 'app/models/solidus_promotions/order_adjuster/discount_order.rb', line 8 def initialize(order, promotions, dry_run: false) @order = order @promotions = promotions @dry_run = dry_run end |
Instance Attribute Details
#dry_run ⇒ Object (readonly)
Returns the value of attribute dry_run.
6 7 8 |
# File 'app/models/solidus_promotions/order_adjuster/discount_order.rb', line 6 def dry_run @dry_run end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
6 7 8 |
# File 'app/models/solidus_promotions/order_adjuster/discount_order.rb', line 6 def order @order end |
#promotions ⇒ Object (readonly)
Returns the value of attribute promotions.
6 7 8 |
# File 'app/models/solidus_promotions/order_adjuster/discount_order.rb', line 6 def promotions @promotions end |
Instance Method Details
#call ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/solidus_promotions/order_adjuster/discount_order.rb', line 14 def call return order if order.shipped? SolidusPromotions::Promotion.ordered_lanes.each do |lane| SolidusPromotions::PromotionLane.set(current_lane: lane) do lane_promotions = promotions.select { |promotion| promotion.lane == lane } lane_benefits = eligible_benefits_for_promotable(lane_promotions.flat_map(&:benefits), order) perform_order_benefits(lane_benefits, lane) unless dry_run adjust_line_items(lane_benefits) adjust_shipments(lane_benefits) adjust_shipping_rates(lane_benefits) end end order end |