Documentation
Feedback
Guides
API Reference

Guides
Orders
Actions in ordersAdding a second address for invoicing an order
Adding a second address for invoicing an order

For B2B businesses, it is common to add to the invoice an address that is different from the one registered for delivery, since the location where the product will be received is often different from the billing address.

VTEX Admin allows you to add a second address only in the case of Pickup Points because there will be only one address for the invoice. For other cases, adding a second address must be done via API, using the orderForm object.

The orderForm is the main object processed by VTEX Checkout, and one of the most important data structures in VTEX stores' architecture.

There are two ways to manipulate data from the orderForm to enter a second address:

  • Using the vtex.js library
  • Through API REST

Although it is possible to create a custom interface superimposed on that of VTEX containing the second address field, we do not recommend it, because it increases the chances of errors in order management.


vtex.js

The vtex.js is a library of JavaScript functions that will do the API requests. The function used for this is the sendAttachment. Fore more information, see the specific library documentation.

API REST

To add a second address to an order via API, make a POST request to the endpoint below:

/api/checkout/pub/orderForm/{{orderFormId}}/attachments/invoiceData

The {{orderFormId}} value must be replaced by the ID of the orderForm that you want to manipulate.

In the orderForm object there is the object invoiceData, which contains information about the order's invoice and contains the field address. This field must be set with the second address you wish to add. The request body looks like the example below:



_17
{
_17
"address": {
_17
"postalCode": "22250-040",
_17
"city": "Rio de Janeiro",
_17
"state": "RJ",
_17
"country": "BRA",
_17
"street": "Praia Botafogo",
_17
"number": "300",
_17
"neighborhood": "Botafogo",
_17
"complement": null,
_17
"reference": null,
_17
"geoCoordinates": [
_17
-43.18218231201172,
_17
-22.94549560546875
_17
]
_17
}
_17
}

Contributors
1
Photo of the contributor
+ 1 contributors
Was this helpful?
Yes
No
Suggest Edits (GitHub)
Contributors
1
Photo of the contributor
+ 1 contributors
On this page