Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save woogists/adaa8cfa6a5c6ba5c008f3e3f0fd5a1c to your computer and use it in GitHub Desktop.
Save woogists/adaa8cfa6a5c6ba5c008f3e3f0fd5a1c to your computer and use it in GitHub Desktop.
[WooCommerce Subscriptions]: Give access to downloadable files even if Subscription is cancelled
<?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;
}
@seb86
Copy link

seb86 commented Jun 28, 2023

Could the permissions also be restricted to the length of the subscription billing period it originally to be?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment