Im running basic product loop with featured image and title. Under that I want download link to be available if the user has bought that digital product.

I tried this but it shows downloadable bought product links under all products in the loop.

global $product;

$downloads = array();

$user_id = get_current_user_id();

$downloads = wc_get_customer_available_downloads($user_id);

if (!empty($downloads)) {

foreach ($downloads as $download) {

if ($download['product_id'] === $product->get_id()) {

echo '<a href="' . $download['download_url'] . '">Download</a>';


I want the downloadable links (that the customer has bought) to be under the bought products only.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.