• 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

    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

    (@webwizardsdev)

    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 – this is our dedicated support platform. Here on www.remarpro.com is for the free (core) plugin,

    Thread Starter ITP TECHNOLOGIE

    (@abitp)

    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

    (@abitp)

    Hello, I have created an Email type custom field that I added in the payment section : 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

    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

    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

    Plugin Author WebWizards

    (@webwizardsdev)

    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

    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:

    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

    (@abitp)

    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

    (@webwizardsdev)

    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

    (@abitp)

    Hum ok ok !

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘ERROR CUSTOM FIELD’ is closed to new replies.