WooCommerceWordPress

How to add SKU to WooCommerce order emails

3
962
2019 / 10 / 07

SKU stands for “Stock Keeping Unit”. SKU is a unique identifier, that refers to the stock of products in the inventory. It is good to add SKU when you add a product but it is not a mandatory field while managing products.

In this article, we will see how to add SKU in WooCommerce order emails, sent to the shop manager or site admin.

When your site has a large number of products or their title is similar, it is always best to have a unique identifier which will help in searching and finding products, here SKU plays the role.

When an order is placed, WooCommerce generates an email to the shop manager. The default representation of order detail is below:

Here you will notice that the products don’t have SKU in them. To add SKU we need to add the following PHP snippet in functions.php of your child theme:

// Adds SKUs to WooCommerce order emails
function w3p_add_sku_to_wc_emails( $args ) {
    $args['show_sku'] = true;
    return $args;
}
add_filter( 'woocommerce_email_order_items_args', 'w3p_add_sku_to_wc_emails' );

 

Once you allow SKU to the order email args, the SKU will become visible in the order emails. For example:

Now, it will be easy for an admin to quickly search the product via SKU.

In the next article, we will learn how to add a product featured thumbnail image in the order email in WooCommerce.

Hi, I am a full-stack web developer with 5+ years of experience in working with different web technologies. Do you want to ask something? just send me a message through the contact form. Please visit my portfolio at hamzamehmood.com. Thanks