# subscription/2.0.0/includes/Frontend/Downloadable.php

Subscriptions for WooCommerce with Stripe Recurring Payments, version 2.0.0. 29 lines.

- Page: https://pluginprobe.com/plugins/subscription/2.0.0/code/includes/Frontend/Downloadable.php
- Raw: https://pluginprobe.com/plugins/subscription/2.0.0/raw/includes/Frontend/Downloadable.php
- Modified: 2025-04-24T09:50:04+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/subscription/2.0.0/code/includes/Frontend/Downloadable.php#L10-L20`.

```php
<?php

namespace SpringDevs\Subscription\Frontend;

use SpringDevs\Subscription\Illuminate\Helper;

/**
 * Downloadable class
 * control Download feature - woocommerce
 */
class Downloadable {

	public function __construct() {
		add_filter( 'woocommerce_customer_get_downloadable_products', array( $this, 'check_download_items' ), 10, 1 );
		add_filter( 'woocommerce_order_get_downloadable_items', array( $this, 'check_download_items' ), 10, 1 );
	}

	public function check_download_items( $downloads ) {
		foreach ( $downloads as $key => $download ) {
			$unactive_items = Helper::subscription_exists( $download['product_id'], array( 'expired', 'cancelled', 'pending' ) );

			if ( $unactive_items ) {
				unset( $downloads[ $key ] );
			}
		}
		return $downloads;
	}
}

```
