Last active
June 28, 2023 02:45
-
-
Save woogists/adaa8cfa6a5c6ba5c008f3e3f0fd5a1c to your computer and use it in GitHub Desktop.
[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
Could the permissions also be restricted to the length of the subscription billing period it originally to be?