Show product thumbnail on woocommerce New Order email

Show product thumbnail on woocommerce New Order email

Content Index :

Show product thumbnail on woocommerce New Order email
Tag : wordpress , By : Alex S
Date : November 24 2020, 05:44 AM

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

How to add Unique nos in order email for each unit of woocommerce product sold

Tag : wordpress , By : Debashree
Date : March 29 2020, 07:55 AM
it helps some times I found a solution if this helpful for you. I think you can store unique nos in database order item meta when product sold. Put this hook in your active theme functions.php file.
add_action( 'woocommerce_add_order_item_meta', 'add_random_number_item_meta', 10, 2 );

function add_random_number_item_meta( $item_id, $item_data ){
  // store each product item quantity in array
  $random = array();
  for( $i = 0; $i < $item_data['quantity']; $i++ )
  $random[$i] = rand(10000, 90000);
  // save unique numbers array each order item
  wc_add_order_item_meta( $item_id, '_unique_nos', $random );   


 $unique_numbers = wc_get_order_item_meta( $item_id,  '_unique_nos', true );
 echo implode( "," , $unique_numbers );

// This will be same both for admin or customer

Get the product name or id in Woocommerce order email notifications

Tag : php , By : Steve M
Date : March 29 2020, 07:55 AM
it helps some times As an order can have many items you can have many products names in an order. You need to get order items first and to loop through each one to get the product names or IDs.
This can be done using the following (that will replace your actual code):
add_action( 'woocommerce_email_after_order_table', 'custom_email_after_order_table', 10, 4 );
function custom_email_after_order_table( $order, $sent_to_admin, $plain_text, $email ) {

    // Displaying the shipping method used
    echo '<p><h4>'.__('Shipping', 'woocommerce').':</h4> '.$order->get_shipping_method().'</p>';

    $product_names = array();

    // Loop thougth order items
    foreach( $order->get_items() as $item_id => $item ){
        $product = $item->get_product(); // Get an instance of the WC_Product object
        $product_id = $item->get_product_id(); // Get the product ID

        // Set each product name in an array
        $product_names[] = $item->get_name(); // Get the product NAME
    // Displaying the product names
    echo '<p><strong>'.__('Product names', 'woocommerce').':</strong> <br>'.implode( ', ', $product_names ).'</p>';

Display product attribute value from order item in Woocommerce email subject

Tag : php , By : avi
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Orders can have many items, and there is some errors in your code since Woocommerce 3.
The code below will search through order items for a specific product attribute (taxonomy) and if it's found, it will display a new custom subject with this product attribute term name value:
add_filter('woocommerce_email_subject_new_order', 'change_admin_email_subject', 1, 2);
function change_admin_email_subject( $subject, $order ) {
    // HERE define the product attribute taxonomy (start always with "pa_")
    $taxonomy = 'pa_color'; //

    // Loop through order items searching for the product attribute defined taxonomy
    foreach( $order->get_items() as $item ){
        // If product attribute is found
        if( $item->get_meta($taxonomy) ){
            // Custom new subject including the product attribute term name
            $subject = sprintf( '[%s] [%s] New customer order (# %s) from %s %s',
                get_term_by('slug', $item->get_meta($taxonomy), $taxonomy )->name, // Term name
                wp_specialchars_decode(get_option('blogname'), ENT_QUOTES),
            break; // Stop the loop

    return $subject;

Product title below the thumbnail in Woocommerce email notifications

Tag : php , By : BinaryBoy
Date : March 29 2020, 07:55 AM
Does that help Updated: If the product image are displayed in your email notifications, you can try the following to display the product title under this image:
add_filter( 'woocommerce_order_item_name', 'product_title_under_thumbnail_emails', 10, 3 );
function product_title_under_thumbnail_emails( $item_name, $item, $is_visible ) {
    // Targeting view order pages only
    if( is_wc_endpoint_url() )
        return $item_name;

    // Get the WC_Product object (from order item)
    $product = $item->get_product();

    if( $product->get_image_id() > 0 && $is_visible )
        $item_name = '<br>' . $item_name;

    return $item_name;

Tag : wordpress , By : TC.
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • How to display first post of each tag
  • Dropdown list of roles, link role name to ID
  • Wordpress – Loading different CSS for different page not working
  • Visual composer Converting Double quote ("some text") into back quote ( ``some text`` )
  • How does WordPress default docker image copies files into the host system?
  • Wordpress add rewrite rule doesn't work for me
  • When can't I update my files on theme editor of Wordpress?
  • Problem with redirect in htaccess wordpress
  • Error with Gatsby plugin Gatsby-Source-Wordpress
  • Can I create a second custom tag system for wordpress?
  • WooCommerce cart items number based on unique products
  • Enabling wordpress with a flask app using nginx
  • I need help generating a custom URL based on the user ID
  • How to add anchor support to a core block?
  • change 'update cart' text in cart page Woocommerce
  • WooCommerce Scheduled Actions Tab
  • Wordpress - Multiple Checkboxes at least 1 checkbox should be required in Contact Form 7
  • Fatal error: Uncaught Error: Cannot use object of type WP_Error as array
  • Add custom classes to "wp_get_attachment_image( $attachment_id)" wordpress function
  • Include image assets in a WordPress Gutenberg Block Plugin
  • Wordpress wants to install itself, rather than run the blog
  • wordpress divi active responsive menu by default
  • Woocommerce Wordpress How do I get the Search term as a dynamic variable
  • How do I write personalized endpoints in Wordpress?
  • Creation of graphic element in wordpress
  • Wordpress deployment after GCE instance creation using custom image
  • How can I find problems with WordPress Plugins?
  • Remove product category placeholder image in Woocommerce
  • System Overview Diagram for Wordpress website?
  • disable one option from the multiple options of the select
  • I have forgotten my wordpress website admin dashboard url
  • Wordpress Website update take time to reflect
  • What part of the code should I edit in order to remove this image in my wordpress site?
  • Woocommerce [products] shortcode - How to order by given product ids atribute?
  • Docker expose service to achieve dockerized wordpress multisite
  • social share icon and text are not refreshing in wordpress (either meta text or text in yeost SEO)
  • how to add more text below blog title in WordPress
  • Wordpress - Theme stuck at loading after migration
  • Is it possible in WordPress to add editable sections in the dashboard?
  • How to test custom classes of my Wordpress theme using phpunit?
  • how to set up 2 virtualhosts with the same root adress?
  • How Can I remove a particular product from an completed order in woocommerce?
  • How to regenerate WordPress thumbnails via Bash?
  • Gravity Form Plugin not Working on Microsoft Edge
  • How to deploy react images inside a wordpress plugin?
  • Cannot get error count in CodeMirror editor
  • I want to hide woocommerce products from the shop loop which the user already puchased
  • how to redirect everysubdomain to main domain? like anysubdomain.domain to domain in wordpress
  • Googled, and failed: Looking for a really good video on WordPress
  • get latest activity from linkedin into website
  • File path without domain name from wp_get_attachment_url()
  • Post repeating in Infinite Scroll in Wordpress
  • wordpress: body_class producing "home" class on custom url
  • Mod Rewrite Rule to take article ID from URL and place a Slash before it
  • How to disable submit button and change text on form submit at Wordpress "contact form 7"
  • .htaccess 301 redirect not working on WordPress site
  • How can i override function wp_insert_user() on Wordpress
  • Does WordPress have the functionality to create a new subdomain?
  • Send thank you email in wordpress after user is redirected from other website
  • WordPress page: Why is <main> tag wrapped by <p> while <div> is not?
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com