Created
August 15, 2025 15:58
-
-
Save greenhornet79/6c6a37cda271157818662c58cf779a84 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_shortcode('endo_user_purchased_downloads', function () { | |
if (! is_user_logged_in()) { | |
return '<p>Please log in to see your downloads.</p>'; | |
} | |
$user_id = get_current_user_id(); | |
$downloads_raw = function_exists('wc_get_customer_available_downloads') | |
? wc_get_customer_available_downloads($user_id) | |
: []; | |
if (empty($downloads_raw)) { | |
return '<p>No purchased downloads yet.</p>'; | |
} | |
ob_start(); | |
?> | |
<ul class="user-purchased-downloads"> | |
<?php foreach($downloads_raw as $data ) { | |
?> | |
<li> | |
<?php | |
echo '<a href="' . $data['download_url'] . '">' . $data['product_name'] . '</a>'; | |
?> | |
</li> | |
<?php | |
} ?> | |
</ul> | |
<?php | |
return ob_get_clean(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment