Connect with us

Hi, what are you looking for?

Technology

How to add CPF in WooCommerce order email

WooCommerce

WooCommerce is one of the most popular eCommerce platforms in the world, allowing online store owners to sell products and services effectively. However, it is often necessary to customize order confirmation emails to include specific information, such as customers' CPF or CNPJ.


With that in mind, in this special article from Coliseu Geek you will learn how to add the CPF or CNPJ in the WooCommerce order email to meet the needs of your business and check the information in a faster and more practical way.

WooCommerce

Before you begin, make sure you are logged into your WordPress admin panel where you manage your WooCommerce site.

  • Access the “Appearance” option in the left sidebar of your WordPress;
  • Go to the “Edit Theme” option or use FTP/SFTP to access your theme;
  • Open the file “functions.php” and go to the last line to add new code:

function kia_display_email_order_user_meta( $order, $sent_to_admin, $plain_text ) {

if ($order->billing_cpf){
echo '

CPF: '. $order->billing_cpf.'

';
}
if ($order->billing_cnpj){
echo '

CNPJ: '. $order->billing_cnpj. '

';
}

}
add_action('woocommerce_email_customer_details', 'kia_display_email_order_user_meta', 30, 3 );


  • Save the file and clear your site's cache (if applicable) for immediate seeding;
  • Now just wait for a new transaction on your website or place a test order.

To ensure that the CPF or CNPJ is being displayed correctly in the order confirmation email, carry out a test purchase in your store. After completing your order, check the confirmation email you will receive. If everything is configured correctly, the confirmation email should display the customer's CPF or CNPJ, as configured.

In summary, customizing the order confirmation email in WooCommerce to include the customer's CPF or CNPJ is a relatively simple process, as long as you can enter the information into the functions.php. By following the steps above, you will be able to provide important information to your customers and improve the shopping experience in your online store.


Written By

My name is Juan de Souza, I'm 24 years old, I'm a businessman, investor, blogger, streamer and podcaster. I started my first business when I was 10 years old, using a dial-up connection in Brazil. Founded businesses like TFX, Coliseu Geek, among others.

Comments
Advertisement
Advertisement

See what we recommend about our Coliseu for you:

PlayStationPlayStation

Tips

PlayStation account is essential for players who want to access online resources, play multiplayer and enjoy all the features offered by the platform. At the...

WordPressWordPress

Tips

If you are migrating from WordPress to Blogger, you may need to export your posts from WordPress and import them into Blogger. In this article, we will show...

bloggerblogger

Tips

If you're thinking of switching from Blogger to WordPress, one of the things you probably need to do is import your posts from...

Java and JavaScriptJava and JavaScript

Technology

There are many similarities and many differences between Java and JavaScript. That's why it's very common to confuse JavaScript with the Java programming language. In...







Disclaimer: We prioritize producing completely impartial content and follow this definition to the letter. Never, under any circumstances, will you find articles and productions with an ideological or political bias on our website. We analyze and question any side or point of view, in order to bring our audience the highest quality and transparent content possible.

Copyright © 2024 Coliseu Geek - All rights reserved. "Coliseu Geek" is a product and property of the company TFX.