Last active
March 9, 2023 07:13
[WooCommerce Subscriptions]: Give access to downloadable files even if Subscription is cancelled
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Access to downloadable files associated with a subscription will, by default, expire | |
* when the subscription is no longer "active" or "pending-cancel". | |
* https://woocommerce.com/document/subscriptions/faq/#section-39 | |
* This snippet overrides that behavior to allow access as per the Download Expiry settng | |
* when the subscription status is "cancelled" | |
*/ | |
add_filter ( 'woocommerce_order_is_download_permitted', 'wc_subscription_download_access_after_cancelled', 10, 2 ); | |
function wc_subscription_download_access_after_cancelled( $is_download_permitted, $subscription ) { | |
if ( $subscription->has_status ( 'cancelled' ) ) { | |
return true; | |
} | |
return $is_download_permitted; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment