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



24
25
26
# File 'app/models/spree/promotion_action.rb', line 24

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

#human_descriptionString

Returns the human description of the promotion action



38
39
40
# File 'app/models/spree/promotion_action.rb', line 38

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

#human_nameString

Returns the human name of the promotion action



31
32
33
# File 'app/models/spree/promotion_action.rb', line 31

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

#keyString

Returns the key of the promotion action



45
46
47
# File 'app/models/spree/promotion_action.rb', line 45

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



17
18
19
# File 'app/models/spree/promotion_action.rb', line 17

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