How can we improve WooCommerce?

plugin WooCommerce EU VAT Number > REST API

For integration purposes with my invoice program, the VAT number that a customer inserts when ordering (made possible with the WooCommerce EU VAT Number plugin) needs to be in the REST API. So this number will be also exported with the order. The VAT number is not there right now.

13 votes
Vote
Sign in
(thinking…)
Password icon
Signed in as (Sign out)
You have left! (?) (thinking…)
Laura shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

2 comments

Sign in
(thinking…)
Password icon
Signed in as (Sign out)
Submitting...
  • Pieter van Kampen commented  ·   ·  Flag as inappropriate

    add_action( 'rest_api_init', 'slug_register_vat' );
    function slug_register_vat() {

    register_rest_field( 'customer', 'vat_number,
    array(
    'get_callback' => 'get_customerMeta',
    'update_callback' => null,
    'schema' => null,

    )
    );
    };

    function get_customerMeta($data,$field_name,$request) {
    return get_user_meta( $data[ 'id' ], $field_name, true );
    };

WooCommerce: Category - Core

Feedback and Knowledge Base