Skip to content

Instantly share code, notes, and snippets.

@bryanmtl
Created June 29, 2012 02:40
Show Gist options
  • Save bryanmtl/3015332 to your computer and use it in GitHub Desktop.
Save bryanmtl/3015332 to your computer and use it in GitHub Desktop.
Allows coupons to be added to Spree orders in a non-complete state, regardless of the date the order was created on
module Extensions
module Spree
module Promotion
extend ActiveSupport::Concern
included do
alias_method_chain :order_activatable?, :no_date_limitation
end
def order_activatable_with_no_date_limitation?(order)
order &&
code.present? ? true : created_at.to_i < order.created_at.to_i &&
!::Spree::Promotion::UNACTIVATABLE_ORDER_STATES.include?(order.state)
end
end
end
end
::Spree::Promotion.send(:include, Extensions::Spree::Promotion)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment