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.
Met dat in gedachten leert u in dit speciale artikel van Nerd Codex hoe u de CPF of CNPJ toevoegt aan de WooCommerce-bestelmail om aan de behoeften van uw bedrijf te voldoen en de informatie op een snellere en meer praktische manier te controleren.
Voordat u begint, moet u ervoor zorgen dat u bent ingelogd op het WordPress-beheerpaneel, waar u uw WooCommerce-site beheert.
- Ga naar de optie ‘Weergave’ in de linkerzijbalk van je WordPress;
- Ga naar de optie “Thema bewerken” of gebruik FTP/SFTP om toegang te krijgen tot uw thema;
- Open het bestand "functies.php" en ga naar de laatste regel om nieuwe code toe te voegen:
functie kia_display_email_order_user_meta( $order, $sent_to_admin, $plain_text ) {
als ($order->facturering_cpf){
echo'
CPF-nummer: '. $order->facturering_cpf.'
';
}
if ($order->billing_cnpj){
echo'
CNPJ-nummer: ‘. $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;
- Wacht nu op een nieuwe transactie op uw website of plaats een testbestelling.
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 functies.phpDoor de bovenstaande stappen te volgen, kunt u uw klanten belangrijke informatie verstrekken en de winkelervaring in uw online winkel verbeteren.
Foto door katoenbro studio