Change column titles from downloads table on Woocommerce emails - php

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

Related

Remove Downloads remaining and expires columns in Woocommerce

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.

Change column name in Downloads section from email notifications in Woocommerce

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.

Remove link from product name on WooCommerce my account downloads

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

Add hidden meta data to product Woocommerce

I've added a custom field to my product for admin only meta data, I have hidden it using CSS.
However it still shows up in emails. Is there any way I can create a custom field where the meta data only shows up in the admin orders page?
You could try to use woocommerce_email_order_meta_fields filter hook to remove this custom field from order metadata, using unset() php function this way:
add_filter( 'woocommerce_email_order_meta_fields', 'wc_email_order_meta_remove_custom_field', 10, 3 );
function wc_email_order_meta_remove_custom_field( $fields, $sent_to_admin, $order ) {
// Replace HERE 'meta_key' by your custom field meta key or slug.
unset($fields['meta_key']);
return $fields;
}
This code goes in function.php file of your active child theme (or theme) or also in any plugin file.
This should work, but not sure as you don't provide any information and code related to the way you have set this custom field.

Show Custom Data in Woocommerce Order Details Admin Area

When a User Buys a Product he can generate up to 3 Serial Keys for his Product. This works fine so far. The User can see his Serials always in "my account"
The Data gets stored in the Database: Table=Usermeta Meta=Product_Serial
So from a Users Perspective evrything works fine but from the Admin Perspective not because the admin can´t see how much Serials the Customer has created and also he cant see the Serials the User is using.
Now I have created a Custom Field in the Theme functions.php with this code:
add_action( 'add_meta_boxes', 'add_meta_boxes' );
function add_meta_boxes()
{
add_meta_box(
'woocommerce-order-my-custom',
__( 'Order Custom' ),
'order_my_custom',
'shop_order',
'side',
'default'
);
}
But from here I don't know how to read out the Serial Key so the admin can see it. :( Any ideas ?
May be i am displaying data in wrong place in your order detail page. But you can check there is multipe hook avilable for this woocommerce/inculdes/admin/meta-boxes-/view/html-order-items.php.
I just take one this hook. Please add this code in functions.php
function my_function_meta_deta() {
echo "I am here";
}
add_action( 'woocommerce_admin_order_totals_after_refunded','my_function_meta_deta', $order->id );
As coder said there is multiple hooks you can also try this out.
add_action('woocommerce_admin_order_data_after_order_details', 'my_custom_order_manipulation_function');
function my_custom_order_manipulation_function( $orderID ) {
//dynamic functionalities / static html to display
}
Credits : Add order metadata to WooCommerce admin order overview

Categories