Class: Spree::PromotionHandler::Shipping
- Inherits:
-
Object
- Object
- Spree::PromotionHandler::Shipping
- Defined in:
- app/models/spree/promotion_handler/shipping.rb
Overview
Used for activating promotions with shipping rules
Instance Attribute Summary collapse
-
#error ⇒ Object
Returns the value of attribute error.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#success ⇒ Object
Returns the value of attribute success.
Instance Method Summary collapse
- #activate ⇒ Object
-
#initialize(order) ⇒ Shipping
constructor
A new instance of Shipping.
Constructor Details
#initialize(order) ⇒ Shipping
Returns a new instance of Shipping.
10 11 12 |
# File 'app/models/spree/promotion_handler/shipping.rb', line 10 def initialize(order) @order = order end |
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
8 9 10 |
# File 'app/models/spree/promotion_handler/shipping.rb', line 8 def error @error end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
7 8 9 |
# File 'app/models/spree/promotion_handler/shipping.rb', line 7 def order @order end |
#success ⇒ Object
Returns the value of attribute success.
8 9 10 |
# File 'app/models/spree/promotion_handler/shipping.rb', line 8 def success @success end |
Instance Method Details
#activate ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/spree/promotion_handler/shipping.rb', line 14 def activate connected_promotions.each do |order_promotion| if order_promotion.promotion.eligible?(order) order_promotion.promotion.activate( order: order, promotion_code: order_promotion.promotion_code, ) end end not_connected_automatic_promotions.each do |promotion| if promotion.eligible?(order) promotion.activate(order: order) end end end |