Method: SolidusSubscriptions::Subscription#can_be_canceled?
- Defined in:
- app/models/solidus_subscriptions/subscription.rb
#can_be_canceled? ⇒ Boolean
This method determines if a subscription may be canceled. Canceled subcriptions will not be processed. By default subscriptions may always be canceled. If this method is overridden to return false, the subscription will be moved to the :pending_cancellation state until it is canceled again and this condition is true.
USE CASE: Subscriptions can only be canceled more than 10 days before they are processed. Override this method to be:
def can_be_canceled?
return true if actionable_date.nil?
(actionable_date - 10.days.from_now.to_date) > 0
end
If a user cancels this subscription less than 10 days before it will be processed the subscription will be bumped into the :pending_cancellation state instead of being canceled. Subscriptions pending cancellation will still be processed.
159 160 161 162 163 164 |
# File 'app/models/solidus_subscriptions/subscription.rb', line 159 def can_be_canceled? return true if actionable_date.nil? cancel_by = actionable_date - SolidusSubscriptions.configuration.minimum_cancellation_notice cancel_by.future? || cancel_by.today? end |