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.
Dans cet esprit, dans cet article spécial de Nerd Codex, vous apprendrez comment ajouter le CPF ou le CNPJ dans l'e-mail de commande WooCommerce pour répondre aux besoins de votre entreprise et vérifier les informations de manière plus rapide et plus pratique.
Avant de commencer, assurez-vous d’être connecté à votre panneau d’administration WordPress où vous gérez votre site WooCommerce.
- Accédez à l’option « Apparence » dans la barre latérale gauche de votre WordPress ;
- Accédez à l’option « Modifier le thème » ou utilisez FTP/SFTP pour accéder à votre thème ;
- Ouvrez le fichier «fonctions.php" et allez à la dernière ligne pour ajouter un nouveau code :
fonction kia_display_email_order_user_meta( $commande, $endu_à_l'administrateur, $texte_plain) {
si ($order->billing_cpf){
écho '
CPF: '. $order->billing_cpf.'
';
}
si ($order->billing_cnpj){
écho '
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;
- Attendez maintenant une nouvelle transaction sur votre site Web ou passez une commande test.
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 fonctions.phpEn suivant les étapes ci-dessus, vous serez en mesure de fournir des informations importantes à vos clients et d’améliorer l’expérience d’achat dans votre boutique en ligne.
Photo de studio cottonbro