Class: Spree::PromotionAction

Inherits:
Object
  • Object
show all
Defined in:
app/models/spree/promotion_action.rb

Instance Method Summary collapse

Instance Method Details

#free_shipping?Boolean

Returns true if the promotion action is a free shipping action

Returns:

  • (Boolean)


26
27
28
# File 'app/models/spree/promotion_action.rb', line 26

def free_shipping?
  type == 'Spree::Promotion::Actions::FreeShipping'
end

#human_descriptionString

Returns the human description of the promotion action

Returns:

  • (String)


40
41
42
# File 'app/models/spree/promotion_action.rb', line 40

def human_description
  Spree.t("promotion_action_types.#{key}.description")
end

#human_nameString

Returns the human name of the promotion action

Returns:

  • (String)

    eg. Free Shipping



33
34
35
# File 'app/models/spree/promotion_action.rb', line 33

def human_name
  Spree.t("promotion_action_types.#{key}.name")
end

#keyString

Returns the key of the promotion action

Returns:

  • (String)

    eg. free_shipping



47
48
49
# File 'app/models/spree/promotion_action.rb', line 47

def key
  type.demodulize.underscore
end

#perform(_options = {}) ⇒ Object

This method should be overridden in subclass Updates the state of the order or performs some other action depending on the subclass options will contain the payload from the event that activated the promotion. This will include the key :user which allows user based actions to be performed in addition to actions on the order



19
20
21
# File 'app/models/spree/promotion_action.rb', line 19

def perform(_options = {})
  raise 'perform should be implemented in a sub-class of PromotionAction'
end