Okay
  Public Ticket #3981021
Custom Field on WooCommerce order rest API
Open

Comments

  •  1
    Simone started the conversation

    Hello,

    in my website www.locatellipins.com I have 3 custom fields in the User Registration Form, they are:

    PIVA = b2bking_custom_field_11838
    CF = b2bking_custom_field_11839
    PEC o SDI = b2bking_custom_field_11840

    If i look into Db, I see these fields in the wp_usermeta table.

    I have a sync tha exports orders form WooCommerce to an ERP software, via WooCommerce order Rest API.

    In the order records the value filled in these fields are missed, in the attachment you can see an excerpt of the record, in which you can see some b2b records, but these 3 custome fields are missed.

    My question is: is it a normal behaviour?
    If yes, is there a way to add these wp_usermeta fields to WooCommerce order rest API?

    Thanks in advance for yout reply.
    Kind regards,
    Simone

  •  2,404
    WebWizards replied

    Hi Simone,

    Glad to assist, 

    I believe that you need to pass those registration fields to the order metadata so they're visible in the WooCommerce REST API.

    By default these usermeta fields aren't passed as order meta. However, this can be solved by adding the fields to the billing section. To do this, please follow these steps:

    1. Go to B2BKing -> Registration Fields
    2. Edit each of your registration fields (PIVA, CF, and PEC o SDI)
    3. Check the boxes shown in this screenshot: https://prnt.sc/udC8xOpuf8RI

    Once these are enabled, the fields will appear on the checkout page under the billing section, and they'll be also saved as order meta, making them accessible via the WooCommerce REST API.

     

    If this solution doesn't work for your specific setup, we could alternatively create a custom code snippet to pass these fields regardless, but I would recommend trying the above solution first as it's more straightforward.

    Let me know your thoughts,

    Kind regards,
    Stefan

  •   Simone replied privately
  •   Simone replied privately
  •   WebWizards replied privately