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.
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'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.
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
I am having difficulties customizing the text location on my Thankyou page/Order Received page. I got some custom text added, but I can't get it into the position I'd like.
See attached image. It is should up at the top, when I would like it under the photo in the "Order Details section)
/**
* Custom text on the receipt page.
*/
function isa_order_received_text( $text, $order ) {
$new = $text . ' If you do not see the download button(s) below, please refresh the page. Processing can take a few minutes.';
return $new;
}
add_filter('woocommerce_thankyou_order_received_text', 'isa_order_received_text', 10, 2 );
To get this easily, you can use woocommerce_thankyou hook with the highest priority (1), this way:
add_action( 'woocommerce_thankyou', 'custom_thankyou_text', 1, 0);
function custom_thankyou_text(){
echo '<p class="thankyou-custom-text">If you do not see the download button(s) below, please refresh the page. Processing can take a few minutes.</p>';
}
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
Code is tested and works.