Title: ERROR CUSTOM FIELD
Last modified: July 19, 2023

---

# ERROR CUSTOM FIELD

 *  Resolved [ITP TECHNOLOGIE](https://wordpress.org/support/users/abitp/)
 * (@abitp)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/error-custom-field/)
 * Hello, I have created an Email type custom field that I added in the payment 
   section
   My first problem is that in my orders, I find myself with the label in
   customMy second issue is that I want to retrieve this email address to also send
   invoices, credit notes, and quotes to it, but it’s not working…This is the code
   found in my functions.php
 *     ```wp-block-code
       Hello, I have created an Email type custom field that I added in the payment section:
   
       My first problem is that in my orders, I find myself with the label in custom:
   
       My second issue is that I want to retrieve this email address to also send invoices, credit notes, and quotes to it, but it's not working...
   
       This is the code found in my functions.php
   
       Why is it that the name of the custom field in my order is "Comptabilité" and not "b2bking_custom_field_171853" ?
       ```
   
 * Why is it that the name of the custom field in my order is “**Comptabilité**”
   and not “**b2bking_custm_field_171853**” ?

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Author [WebWizards](https://wordpress.org/support/users/webwizardsdev/)
 * (@webwizardsdev)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/error-custom-field/#post-16906993)
 * Hi there!
 * Thank you for using our plugin,
 * > My first problem is that in my orders, I find myself with the label in custom
 * Can you please clarify, where is the field in orders? and where do you want it
   to be? If you have a screenshot, it would be helpful.
 * > My second issue is that I want to retrieve this email address to also send 
   > invoices, credit notes, and quotes to it, but it’s not working…
 * How would that work? based on the custom code? I am not able to see any code (
   functions.php) in your previous message, I think there was a formatting error
   when you sent the message.
 * > Why is it that the name of the custom field in my order is “**Comptabilité**”
   > and not “**b2bking_custm_field_171853**” ?
 * The name of the fields should be the same – if the field is named ‘**Comptabilité**‘
   on the backend order page, the only explanation I can think of is that some other
   plugin modifies it.
 * **If you can share some screenshots so we can better understand what you are 
   looking at, it would be very helpful.**
 * Also if you are using the Pro plugin, it is best to open tickets with us at [https://webwizards.ticksy.com](https://webwizards.ticksy.com)–
   this is our dedicated support platform. Here on wordpress.org is for the free(
   core) plugin,
 *  Thread Starter [ITP TECHNOLOGIE](https://wordpress.org/support/users/abitp/)
 * (@abitp)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/error-custom-field/#post-16908812)
 * I’m sorry, I don’t understand why my post was duplicated and why the moderation
   approved this one instead of the other one containing screenshots, even though
   I marked in response that this post was the wrong one ^^
   I’m reposting my original
   post with the correct functions code and the screenshots just in the response.
 *  Thread Starter [ITP TECHNOLOGIE](https://wordpress.org/support/users/abitp/)
 * (@abitp)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/error-custom-field/#post-16908873)
 * Hello, I have created an Email type custom field that I added in the payment 
   section : [https://prnt.sc/YxsM_o5ETHsB](https://prnt.sc/YxsM_o5ETHsB)
 * My first problem is that in my orders, I find myself with the label in custom:
   [https://prnt.sc/RgLS51U-DyI3](https://prnt.sc/RgLS51U-DyI3)
 * My second issue is that I want to retrieve this email address to also send invoices,
   credit notes, and quotes to it, but it’s not working…
 * This is the code found in my functions.php
 *     ```wp-block-code
       add_filter( 'woocommerce_email_headers', 'woocommerce_emails_bcc_copy', 10, 3);
       function woocommerce_emails_bcc_copy( $headers, $email_id, $order, $email = null ) {
           // Si la notification par e-mail est "Completed order" ou "Processing order"
           if ( in_array( $email_id, array('refunded', 'completed', 'expedier') ) ) {
               // Remplacez 'b2bking_custom_field_171853' par la clé de métadonnées réelle de votre champ personnalisé
               if ( $extra_email_address = $order->get_meta( 'Comptabilité' ) ) {
                   $billing_full_name = $order->get_formatted_billing_full_name();
                   $headers .= 'BCC: ' . $billing_full_name . ' <' . $extra_email_address . '>' . "\r\n";
               }
           }
           return $headers;
       }
       ```
   
 * Why is it that the name of the custom field in my order is “**Comptabilité**”
   and not “**b2bking_custm_field_171853**” ?
 * Another screen :
   [https://prnt.sc/BLx76OPxk8xP](https://prnt.sc/BLx76OPxk8xP)
 *  Plugin Author [WebWizards](https://wordpress.org/support/users/webwizardsdev/)
 * (@webwizardsdev)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/error-custom-field/#post-16912135)
 * Thank you for clarifying that,
 * (1) I tested now by placing an order:
 * The field is saved under both Label and ‘b2bking_custom_field_*”:
 * [https://prnt.sc/gwD7Mqqe6qSZ](https://prnt.sc/gwD7Mqqe6qSZ)
 * This is in order to make it easier to find the information. But it should be 
   saved under both.
 * (2) Your code is good, but the email IDs are wrong.
 * The correct line would be:
 * if ( in_array( $email_id, array(‘**customer_refunded_order**‘, ‘**customer_completed_order**‘))){
 * On my site, I tested this code and it worked to add the BCC:
 *     ```wp-block-code
       add_filter( 'woocommerce_email_headers', 'woocommerce_emails_bcc_copy', 10, 3);
       function woocommerce_emails_bcc_copy( $headers, $email_id, $order, $email = null ) {
           // Si la notification par e-mail est "Completed order" ou "Processing order"
           if ( in_array( $email_id, array('customer_refunded_order', 'customer_completed_order') ) ) {
               // Remplacez 'b2bking_custom_field_171853' par la clé de métadonnées réelle de votre champ personnalisé
               if ( $extra_email_address = $order->get_meta( 'b2bking_custom_field_1044' ) ) {
                   $billing_full_name = $order->get_formatted_billing_full_name();
                   $headers .= 'BCC: ' . $billing_full_name . ' <' . $extra_email_address . '>' . "\r\n";
               }
           }
           return $headers;
       }
       ```
   
 *  Thread Starter [ITP TECHNOLOGIE](https://wordpress.org/support/users/abitp/)
 * (@abitp)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/error-custom-field/#post-16912483)
 * I don’t understand what I need to do to not have “Comptabilité” in the custom
   field, but just the ID of the input like in your example (first red rectangle).
 *  Plugin Author [WebWizards](https://wordpress.org/support/users/webwizardsdev/)
 * (@webwizardsdev)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/error-custom-field/#post-16913329)
 * There is nothing you can do to not have “Comptabilite”, but you should have both
   that AND the ID. So you should have both rectangles like in my example.
 * Do you not have the other one? **b2bking_custom_field_171853** ?
 *  Thread Starter [ITP TECHNOLOGIE](https://wordpress.org/support/users/abitp/)
 * (@abitp)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/error-custom-field/#post-16917695)
 * Hum ok ok !

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘ERROR CUSTOM FIELD’ is closed to new replies.

 * ![](https://ps.w.org/b2bking-wholesale-for-woocommerce/assets/icon-256x256.gif?
   rev=3025903)
 * [B2BKing — Ultimate WooCommerce B2B and Wholesale Plugin — Wholesale Prices, Bulk Order Form & More](https://wordpress.org/plugins/b2bking-wholesale-for-woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/b2bking-wholesale-for-woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/b2bking-wholesale-for-woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/b2bking-wholesale-for-woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/b2bking-wholesale-for-woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/b2bking-wholesale-for-woocommerce/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [ITP TECHNOLOGIE](https://wordpress.org/support/users/abitp/)
 * Last activity: [2 years, 10 months ago](https://wordpress.org/support/topic/error-custom-field/#post-16917695)
 * Status: resolved