Devs

How to add CPF in WooCommerce order email

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 in Brazil.

With that in mind, in this special article from Nerd Codex, 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.


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.

Photo by cottonbro studio

Comments

Recommended Posts for You

LGBTQIA+

Check out the full review of Netflix's Heartstopper series and find out if the Heartstopper series delivers everything it promises in full!

Cinema

“One of the most memorable cartoons of the 20th and 21st centuries. Its story, characters and writing are utterly captivating. “Little Bear” is known...

Curiosities

Super Mario World, also known as “Super Mario Bros. 4” in Japan, is without a doubt one of the most popular games of all...

Cinema

“Courage the Cowardly Dog” tells the story of Courage, a dog who’s easily scared and lives on a farm with Muriel and Eustace Bagge...

Cinema

Who doesn’t know this epic cartoon from Hanna-Barbera, Wacky Races, where eleven competitors vied in every episode for the world title of “World’s Wackiest...

Cinema

Sagwa, one of the best cartoons still airing on the Futura channel. In fact, all the shows on Futura are excellent. It tells the...

Cinema

“Do you remember the classic cartoon Timon and Pumbaa? It’s an animated TV series produced by Walt Disney Animation, starring the warthog and meerkat...

Cinema

At the end of the 1930s, animation was at its peak. It was called the “Golden Age” by many film enthusiasts, where classic characters...

Curiosities

Grand Theft Auto V (GTA V) is known for its vast open-world gameplay, where players can explore, complete missions, or just cause chaos. One...

Cinema

Woody Woodpecker, one of the most beloved characters of all time. Adored by children, teenagers, and adults alike. The show itself dates back to...

Others

“Castelo Rá‑Tim‑Bum” premiered in 1994 on TV Cultura, delighting fans of the original “Rá‑Tim‑Bum” who were tired of its reruns, as well as other...

Tech

If you grew up playing console games in the 1980s and 90s and never heard this one, count yourself lucky—very lucky. Here’s the urban...

Cinema

Walt Disney, one of the largest and most influential entertainment giants in the world, has a long history of innovation in animation. From its...

Games

“Nintendo 64” is Nintendo’s third home video game console. Commonly abbreviated as “N64,” it launched on June 23, 1996 (Japan) and on September 29 in the United States....

Games

How about transforming your Minecraft into an even more immersive game? With that in mind, the “Realistico” Mod Pack was developed—a texture pack with...

Games

It's time to talk about Far Cry 4: a new game in the iconic open-world franchise that first arrived over 10 years ago with paradisiacal...

Tech

We’ve all heard about the risks of being tracked online and how cybercriminals exploit vulnerabilities to access personal data. One particular topic that often...

Games

<iframe width="1665" height="705" src="https://www.youtube.com/embed/Xg5ajToIUoM" title="Just Dance 2016 - Real dancers behind the scenes #1" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>You’ve...

Games

Need For Speed Heat has finally hit the streets and is increasingly reminiscent of the franchise’s golden-era titles, such as Need For Speed Underground...

Games

Recently, Plants vs. Zombies Garden Warfare was released—it’s the new game from PopCap, famous for its mobile hits. This time, we have a review...

Copyright © 2026 Juan de Souza - All Rights Reserved. Hosting by TFX.

Exit mobile version