• Resolved mouli90

    (@mouli90)


    Hello!,

    first of all, thank you for the great plugin.

    I would have one question regarding the custom user billing field. I have one of them that had been created in the way as shown below. Currently, your plugin is bypassing it so I would like to ask you if there is any way to have the field included. Thank you in advance for letting me know.

    add_filter(‘woocommerce_admin_billing_fields’, ‘order_admin_custom_fields’);

    function order_admin_custom_fields($fields)
    {
    global $the_order;

    $fields[‘CUSTOM_ID’] = array(
    ‘label’ => __(‘Custom name’, ‘woocommerce’) ,
    ‘show’ => true,
    );

    return $fields;
    }

    • This topic was modified 3 years, 5 months ago by mouli90.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author dansart

    (@dansart)

    Hi Mouli90

    Thanks a lot. Glad you find this Plugin useful.
    That’s true. Only the default fields are getting saved.
    I put this on the feature List of Version 1.2.
    The release is expected till the end of the year.

    Best,
    Daniel

    Plugin Author dansart

    (@dansart)

    Hi Mouli90

    Version 1.2 is out now!
    Custom Fields are getting saved in the usermeta as well.
    It will take the ID of the field and prefix it with “shipping_” or “billing_”.

    Give it a try and let me know.
    Best, Daniel

    Thread Starter mouli90

    (@mouli90)

    Hi Daniel,

    sorry for a bit of a delay in answering. And thanks for such quick response regarding the custom fields.

    I created a new custom field having “billing_” prefix but it did not seem to work. Basically, I have created a new order and filled in a customer billing data, saved it and right after created a new order in which I wanted to retrieve the previous customer with its data through the drop-down field ( https://prnt.sc/1vz38d8 ). All fields got populated except of the custom field I had created.

    For creating the custom field I used the exact function definition as shown in my very first message so if there is something I am doing wrong, please let me know.

    Many thanks

    Jan

    Plugin Author dansart

    (@dansart)

    Hi Jan
    Thanks for your feedback. I did some testing.
    Unfortunately, I could not reproduce the issue.
    The Code I’m using in this example:

    add_filter("woocommerce_admin_billing_fields", "order_admin_custom_fields");
    add_filter("woocommerce_admin_shipping_fields", "order_admin_custom_fields");
    
    function order_admin_custom_fields($fields)
    {
    global $the_order;
    
    $fields["dans_art_custom_field"] = array(
    "label" => __("This is a Custom Field", "woocommerce") ,
    "show" => true,
    );
    
    return $fields;
    }

    This adds both, a billing and a shipping field.
    Here you can see the Fields before creation.
    https://prnt.sc/1w05zx4

    In a new order, when the user is selected, the billing and shipping fields are getting filled out automatically.
    https://prnt.sc/1w06293

    And this is how it looks in the Database (wp_usermeta)
    https://prnt.sc/1w061cp

    Can you share with me, what kind of data ends up in the database regarding the custom field?
    Best, Daniel

    Thread Starter mouli90

    (@mouli90)

    Hi Daniel,

    Thank you for the example you sent. I discovered that the issue I had was in the ID that I named already with the prefix “billing_” e.g. “$fields[“billing_custom”] … “. After removing the prefix from ID everything worked smoothly :).

    Thank you for this additional functionality that made the plugin much more flexible.

    Have a great day!

    Jan

    Plugin Author dansart

    (@dansart)

    Hi Jan

    Thanks for your feedback. Good to hear ??

    Have a great day!

    Daniel

    • This reply was modified 3 years, 5 months ago by dansart.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘A custom user billing field’ is closed to new replies.