Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment