In Woocommerce when we go to My account "Downloads" section, a list of downloads is displayed which contain product name(linked to the product) and link to download the file.
Is there a way to remove the link of product and just display product name?
Update 3:
Here is the way to remove the product link from the product name in My account downloads:
// Display the product name without the link
add_action( 'woocommerce_account_downloads_column_download-product', 'custom_account_downloads_product_column' );
function custom_account_downloads_product_column( $download ){
// Display the product name without the link
echo esc_html( $download['product_name'] );
}
Code goes in function.php file of your active child theme (or active theme). Tested and works
Related
I'm trying to change the "product" column title for downloadable products on customers email notification after completing a purchase.
Any advice would be greatly appreciated.
Using woocommerce_email_downloads_columns filter hook will allow you to change the column label name to something else:
// Change email downloads specific column label name
add_filter( 'woocommerce_email_downloads_columns', 'filter_wc_email_downloads_columns' );
function filter_wc_email_downloads_columns( $columns ) {
$columns['download-product'] = __( 'Name', 'woocommerce' );
return $columns;
}
Code goes in functions.php file of your active child theme (or active theme). Tested and works.
Similar: Change column titles from downloads table on Woocommerce Thankyou page
Every night I load in a CSV with my suppliers products. They remove and add products in every CSV. If a product is not in the CSV anymore and it was in the CSV before, my plugin will put the product visibility on hidden. This way the link still works, so no 404 errors in search console etc, but the product is not showing in my shop.
However, some customers still land on these links from different domains, i.e. google. They land on the "invisible product" and they have the possibility to click on the "in cart" button while the product is not available anymore.
Therefor my question: How can I (in functions.php?) make sure that when a product's visibility is hidden, the cart button is removed (a simple display: none; will do).
I use WP Import for importing the CSV and the way products are put on visibility:hidden is like this:
function my_is_post_to_delete($is_post_to_delete, $post_id, $import) {
// Get an instance of the product variation from a defined ID
$my_product = wc_get_product($post_id);
// Change the product visibility
$my_product->set_catalog_visibility('hidden');
// Save and sync the product visibility
$my_product->save();
return false;
}
So I need something like this:
If product_visibility is 'hidden' then remove add to cart button.
You can simply use woocommerce_is_purchasable dedicated filter hook when the product catalog visibility is "hidden", this way:
add_filter('woocommerce_is_purchasable', 'filter_product_is_purchasable', 10, 2 );
function filter_product_is_purchasable( $purchasable, $product ) {
if( 'hidden' === $product->get_catalog_visibility() ) {
$purchasable = false;
}
return $purchasable;
}
Code goes in functions.php file of your active child theme (or active theme). Tested and works.
Note: If customer has a previous cart session with the product in it, it will be removed from it.
Update - For external (or affiliate) products try to use the following instead:
add_action( 'woocommerce_single_product_summary', 'remove_product_add_to_cart_button', 4 );
function remove_product_add_to_cart_button(){
global $product;
if( $product->is_type('external') && 'hidden' === $product->get_catalog_visibility() ) {
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
}
}
Code goes in functions.php file of your active child theme (or active theme). Tested and works.
I am trying to reduce the table so it's just the download product title and the button to download the product. Here are the columns I want to remove "Downloads remaining" and "Expires" from Order received and My Account…
Here is a screenshot.
To be able to only see the Product Name and Download Button
Try the following code that should remove "Downloads remaining" and "Downloads Expires" from everywhere (even on email notifications):
add_action( 'woocommerce_account_downloads_columns', 'custom_downloads_columns', 10, 1 ); // Orders and account
add_action( 'woocommerce_email_downloads_columns', 'custom_downloads_columns', 10, 1 ); // Email notifications
function custom_downloads_columns( $columns ){
// Removing "Download expires" column
if(isset($columns['download-expires']))
unset($columns['download-expires']);
// Removing "Download remaining" column
if(isset($columns['download-remaining']))
unset($columns['download-remaining']);
return $columns;
}
Code goes in function.php file of your active child theme (or active theme). It should works.
I'm creating a website with downloadable products with WooCommerce. When users buy a product and receive an email, I want to customize the table of downloadable products in the email. More specific I only want to change the following:
Only thing I want to do is change 'Downloads' and 'download' to something else…
With some research, I thought I had the answer. I changed some things in order/order-details.php and order/order-downloads.php. But I think I didn't do it correctly.
Can someone tell me what I have to change exactly?
To change the title "Downloads", the right template involved is emails/email-downloads.php line 22
?><h2 class="woocommerce-order-downloads__title"><?php esc_html_e( 'Downloads', 'woocommerce' ); ?></h2>
To change the column label name "Download", you will use the following code:
add_filter('woocommerce_email_downloads_columns', 'custom_email_downloads_columns', 10, 1);
function custom_email_downloads_columns( $columns ){
$columns['download-file'] = __("New name", "woocommerce");
return $columns;
}
Code goes in function.php file of your active child theme (or active theme). Tested and work.
I'd like to add a DIV under the title of my Shop page, but ONLY my main shop page.
I added some code in " archive-product.php " but then it display the code on every shop page.
In fact i just need a DIV saying " choose a category below " on the main Shop Page.
Thnaks a lot for your help!
Vince
Instead of overriding archive-product.php template, You can use the following custom hooked function, that will add a custom <div> below the title in shop page only:
add_action( 'woocommerce_archive_description', 'additional_div_in_shop', 5 );
function additional_div_in_shop() {
// Only on "shop" archives pages
if( ! is_shop() ) return;
// Output the div
?>
<div class="shop-below-title"><?php _e( "Choose a category below", "woocommerce" ); ?></div>
<?php
}
Code goes in function.php file of your active child theme (or active theme).
Tested and works.
Related Docs: woocommerce conditional tags
You can add that div conditionally like the following and then the div will be shown only on shop page
if ( is_shop() ) {
echo '<div>Choose a category below</div>';
}
I know this is an old post but, there is a page selected as the shop page for woocommerce. U can simply switch back to classic editor and add a div in the text section of the page u selected in the woocommerce settings. That way u don't need child theme or anything.