PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / trunk
Subscriptions for WooCommerce with Stripe Recurring Payments vtrunk
1.11.2 1.11.1 1.11.0 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.6 1.9.5 trunk 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 All 60 releases
subscription / includes / Frontend / Downloadable.php

Downloadable.php in Subscriptions for WooCommerce with Stripe Recurring Payments trunk, at includes/Frontend/Downloadable.php

29 lines 771 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SpringDevs\Subscription\Frontend;
4
5 use SpringDevs\Subscription\Illuminate\Helper;
6
7 /**
8 * Downloadable class
9 * control Download feature - woocommerce
10 */
11 class Downloadable {
12
13 public function __construct() {
14 add_filter( 'woocommerce_customer_get_downloadable_products', array( $this, 'check_download_items' ), 10, 1 );
15 add_filter( 'woocommerce_order_get_downloadable_items', array( $this, 'check_download_items' ), 10, 1 );
16 }
17
18 public function check_download_items( $downloads ) {
19 foreach ( $downloads as $key => $download ) {
20 $unactive_items = Helper::subscription_exists( $download['product_id'], array( 'expired', 'cancelled', 'pending' ) );
21
22 if ( $unactive_items ) {
23 unset( $downloads[ $key ] );
24 }
25 }
26 return $downloads;
27 }
28 }
29