get_downloads( array( 'order_id' => $post->ID, 'orderby' => 'product_id', ) ); $product = null; $loop = 0; $file_counter = 1; if ( $download_permissions && sizeof( $download_permissions ) > 0 ) { foreach ( $download_permissions as $download ) { if ( ! $product || $product->get_id() !== $download->get_product_id() ) { $product = wc_get_product( $download->get_product_id() ); $file_counter = 1; } // don't show permissions to files that have since been removed. if ( ! $product || ! $product->exists() || ! $product->has_file( $download->get_download_id() ) ) { continue; } // Show file title instead of count if set. $file = $product->get_file( $download->get_download_id() ); $file_count = isset( $file['name'] ) ? $file['name'] : sprintf( __( 'File %d', 'woocommerce' ), $file_counter ); include __DIR__ . DIRECTORY_SEPARATOR . 'views/html-order-download-permission.php'; $loop++; $file_counter++; } } ?>

set_downloads_remaining( wc_clean( $downloads_remaining[ $i ] ) ); $download->set_access_expires( array_key_exists( $i, $access_expires ) && '' !== $access_expires[ $i ] ? strtotime( $access_expires[ $i ] ) : '' ); $download->save(); } } } }