Class: SolidusFriendlyPromotions::Conditions::ShippingMethod

Inherits:
SolidusFriendlyPromotions::Condition show all
Includes:
ShipmentLevelCondition
Defined in:
app/models/solidus_friendly_promotions/conditions/shipping_method.rb

Instance Method Summary collapse

Methods included from ShipmentLevelCondition

#level

Methods inherited from SolidusFriendlyPromotions::Condition

#eligibility_errors, #level, #preload_relations, #to_partial_path, #updateable?

Instance Method Details

#applicable?(promotable) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'app/models/solidus_friendly_promotions/conditions/shipping_method.rb', line 10

def applicable?(promotable)
  promotable.is_a?(Spree::Shipment) || promotable.is_a?(Spree::ShippingRate)
end

#eligible?(promotable) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'app/models/solidus_friendly_promotions/conditions/shipping_method.rb', line 14

def eligible?(promotable)
  promotable.shipping_method&.id&.in?(preferred_shipping_method_ids.map(&:to_i))
end