Does anyone know how I can display a download link on a Woocommerce Cart page? I ask user upload a PDF file and need to display the file download link for each cart item. It appears that Woocommerce strips of html and tags and al I see is just the label “download”. The view source code shows no url nor a href tags,
Here is my plugin file.
add_filter('woocommerce_get_item_data', 'display_custom_data_in_cart', 10, 2);
function display_custom_data_in_cart($item_data, $cart_item) {
if (!empty($cart_item['rx_type'])) {
$item_data[] = array(
'name' => 'RX Type Details',
'value' => $cart_item['rx_type']
);
error_log('RX Type Details: ' . $cart_item['rx_type']);
}
if (!empty($cart_item['calculations'])) {
$item_data[] = array(
'name' => 'Cost per Lens',
'value' => '$' . number_format($cart_item['calculations'], 2)
);
error_log('Calculations: ' . $cart_item['calculations']);
}
if (!empty($cart_item['uploaded_file_url'])) {
$item_data[] = array(
'name' => 'Uploaded Prescription',
'value' => esc_html($cart_item['uploaded_file_url']) // Display the URL as plain text
);
error_log('Uploaded Prescription URL: ' . $cart_item['uploaded_file_url']);
} else {
error_log('No uploaded file URL found in cart item data.');
}
return $item_data;
}
I tried removing wp_kses_post cart-item-data.php template file but it did not make any differences
Dongchul Chung is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.