• Resolved Nikita

    (@delfniki)


    Guys,

    googling for 3 days already…please help..:)

    How can I rename fields in JSON, generated by X-Wc-Webhook-Topic:order.created webhook?

    For example:
    “shipping”: {
    “first_name”: “Nikita”,
    “last_name”: “P”,
    “company”: “”,
    “address_1”: “”,
    “address_2”: “”,
    “city”: “”,
    “state”: “”,
    “postcode”: “”,
    “country”: “NL”

    “first_name” should become “Naam”

    And

    “line_items”: [{
    “id”: 2233,
    “name”: “Honingkracht”,
    “product_id”: 1290,
    “variation_id”: 0,
    “quantity”: 1,
    “tax_class”: “gereduceerd-tarief”,
    “subtotal”: “6.13”,
    “subtotal_tax”: “0.37”,
    “total”: “6.13”,
    “total_tax”: “0.37”,
    “taxes”: [{
    “id”: 52,
    “total”: “0.367925”,
    “subtotal”: “0.367925”
    }],
    “meta_data”: [],
    “sku”: “22204”,
    “price”: 6.132075

    sku should become artikel

    Please, help will be much appreciated..

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi there,

    How can I rename fields in JSON, generated by X-Wc-Webhook-Topic:order.created webhook?

    The JSON field names should not be changed – they should stay the default set by Woocmmerce. What you would need to do is get the data via JSON and then manipulate it to display in a translated way if you wanted.

    Best,

    Thread Starter Nikita

    (@delfniki)

    hi Mikey,

    Thanks for quick support and explanation.
    Not sure if I may ask it here, could you please give me en example of filter / action to add to functions.php to perform this task?
    For example to retrieve order “line_items” [{“sku”: “22204” }] ? but rename sku to something else?

    I think i will be able to understand the logic and extend it to other fields i need to be translated.

    If possible and if you have a moment. Thanks in any case.

    Hi @delfniki,

    Not sure if I may ask it here, could you please give me en example of filter / action to add to functions.php to perform this task?
    For example to retrieve order “line_items” [{“sku”: “22204” }] ? but rename sku to something else?

    I would suggest looking at the REST API documentation here:
    https://docs.woocommerce.com/document/woocommerce-rest-api/

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Rename field in generated JSON’ is closed to new replies.