Documentation
Feedback
Guides
VTEX IO Apps

VTEX IO Apps
DeprecatedQuerying B2B order statuses
Querying B2B order statuses

This guide references the B2B Orders app, which is deprecated and has limited support in favor of the B2B Orders History app. It is strongly recommended to update your store theme with the B2B Suite app for compatibility and to follow the component's evolution. Note that the B2B Orders app is not compatible with the B2B Suite solution, and these instructions are not applicable for stores using the B2B Suite. For B2B Suite users, please consult the B2B Orders History documentation instead.

In a B2B business model, your company and your partners may need to share selected information, such as order statuses. This is necessary to show the status of external orders — orders made outside VTEX — to customers on your ecommerce, for example.

For these scenarios, we recommend that you install and set up the B2B Orders app in your VTEX account. By communicating with your Enterprise Resource Planning (ERP), this app allows your business’ customers to securely check their order status at any time they want.

Check the following sections for information on the ERP API requirements and on how to install the B2B Orders app in your store.

ERP API requirements

The B2B Orders app comes with a specific pattern for communicating with the ERP API. For the query to work properly, your ERP API must have different endpoints for each of the following scenarios:

If you have specific business needs which are not satisfied by the scenarios presented, you can customize the B2B Orders app.

The possible requests and response formats for each of the ERP API's required endpoints are presented below.

Search order

By exposing the POST api/v1/pedido/pesquisa endpoint, it will be possible to search for external orders by filling one of the following objects: porPeriodo, porCodigo or porNotaFiscal.

Request format

AttributeTypeDescription
revendaIdintegerResale ID number.
porCodigostringDefinition of order code or ID that can be used to filter the query.
codigostringOrder code, such as the order ID, the client ID or the ERP order ID.
tipointegerType of code that will be used in the query.

If you want to filter the query using PedidoId (web order number, which is the identification number of the order placed through the store’s website), the value should be 0.

To filter the query using PedidoClienteId (identification number associated with the customer who made the purchase), the value should be 1.

To filter the query using PedidoErpId (ERP order number), set the value to 2.
porPeriodoobjectDefinition of dates to filter the query.
dataInicialstringStart date of the query.
dataFimstringEnd date of the query.
porNotaFiscalobjectDefinition of invoice data to filter the query.
notaFiscalstringInvoice number.
serieNotaFiscalstringInvoice serial number.

Request body example


_15
{
_15
"revendaId": 55,
_15
"porCodigo": {
_15
"codigo": "1234",
_15
"tipo": 1
_15
},
_15
"porPeriodo": {
_15
"dataInicial": "2022-07-11T23:28:30Z",
_15
"dataFim": "2022-10-11T23:28:30Z"
_15
},
_15
"porNotaFiscal": {
_15
"notaFiscal": "987654321",
_15
"serieNotaFiscal": "123"
_15
}
_15
}

Response format

AttributeTypeDescription
itensarray of objectsArray of objects containing orders data.
objectObject containing order data.
pedidoErpIdstringERP order number, which is the identification number of the order placed through the store ERP.
pedidoClienteIdstringIdentification number associated with the customer who made the purchase.
totalPedidonumberTotal value of the order.
statusintegerOrder status.
dataPedidostringDate of the order.
observacaostringAdditional order information.
notaFiscalstringInvoice number.
serieNotaFiscalstringInvoice serial number.

Response body example


_14
{
_14
"itens": [
_14
{
_14
"pedidoErpId": "12345",
_14
"pedidoClienteId": "10987",
_14
"totalPedido": 456,
_14
"status": 1,
_14
"dataPedido": "2022-10-11T23:28:30Z",
_14
"observacao": "",
_14
"notaFiscal": "987654321",
_14
"serieNotaFiscal": "123"
_14
}
_14
]
_14
}

Search order details

By exposing the GET api/v1/pedido?pedidoErpId={pedidoErpId}&revendaId={revendaId} endpoint, it will be possible to fetch the details of a specific order directly from the ERP.

Request format

AttributeTypeDescription
pedidoErpIdstringERP order number, which is the identification number of the order placed through the store ERP.
revendaIdintegerResale ID number.

Request body example


_10
{
_10
"pedidoErpId": "12345",
_10
"revendaId": 2
_10
}

Response format

AttributeTypeDescription
pedidoErpIdstringERP order number, which is the identification number of the order placed through the store ERP.
statusintegerOrder status.
itensarray of objectsArray of objects containing information about each item in the order.
objectObject containing information about an item.
partNumberstring
descricaoDoProdutostringProduct description.
quantidadenumberItem quantity.
valorUnitarionumberPrice per item.
valorTotalnumberTotal value.
comissaonumberComission.
revendaIdintegerResale ID number.
clienteFinalIdstringCustomer's ID.
clienteFinalCnpjstringCustomer's CNPJ number.
clienteFinalCpfstringCustomer's CPF number.
valorFretenumberFreight value.
valorTotalPedidonumberTotal order value.
dataPedidostringDate of the order.
dataPrevisaoEntregastringDelivery date.
observacaostringAdditional information.
notaFiscalstringInvoice number.
serieNotaFiscalstringInvoice serial number.
linkTransportadorastringCarrier link.
formattedAddresstringAddress.
zipcodestringZIP code.
methodPaymentstringPayment method used in the order.
corpnamestringCorporate name.
corpemailstringCorporate email.
cityStatestringCity and state.
methodPaymentInfostringInformation about the payment method used in the order.
centrosDeDistribuicaoarray of objectsArray containing objects that represent each Distribution Center.
objectObject containing information per Distribution Center.
distributionCenterPrefixstringPrefix of the Distribution Center.
itensarray of objectsArray containing objects with order items information.
objectObject with order items information.
partNumberstring
descricaoDoProdutostringProduct description.
quantidadenumberItem quantity.
valorUnitarionumberPrice per item.
valorTotalnumberTotal value.
comissaonumberComission.
valorFretenumberFreight value.
valorTotalCDnumberTotal delivery value including Distribution Center costs.

Response body example


_50
{
_50
"pedidoErpId": "12345",
_50
"status": 0,
_50
"itens": [
_50
{
_50
"partNumber": "123",
_50
"descricaoDoProduto": "Beautifully handmade laptop case/sleeve made in the Nepal Himalaya. It can be slipped inside your backpack or carried alone with space for all your work bits and pieces!",
_50
"quantidade": 2.0,
_50
"valorUnitario": 22.0,
_50
"valorTotal": 44.0,
_50
"comissao": 4.0
_50
}
_50
],
_50
"revendaId": 2,
_50
"clienteFinalId": "109",
_50
"clienteFinalCnpj": "55616766000197",
_50
"clienteFinalCpf": "48654007028",
_50
"valorFrete": 10.0,
_50
"valorTotalPedido": 58.0,
_50
"dataPedido": "2022-10-11T23:28:30Z",
_50
"dataPrevisaoEntrega": "2022-10-11T23:28:30Z",
_50
"observacao": "",
_50
"notaFiscal": "987654321",
_50
"serieNotaFiscal": "123",
_50
"linkTransportadora": "https://www.google.com/",
_50
"formattedAddres": "Quadra SHIN QI 4 Conjunto 3",
_50
"zipcode": "71510230",
_50
"methodPayment": "Credit Card",
_50
"corpname": "Knowledge Inc.",
_50
"corpemail": "qlrmrfuo@knowledgemd.com",
_50
"cityState": "BrasiliaDF",
_50
"methodPaymentInfo": "Credit Card",
_50
"centrosDeDistribuicao": [
_50
{
_50
"distributionCenterPrefix": "CD1",
_50
"itens": [
_50
{
_50
"partNumber": "123",
_50
"descricaoDoProduto": "Beautifully handmade laptop case/sleeve made in the Nepal Himalaya. It can be slipped inside your backpack or carried alone with space for all your work bits and pieces!",
_50
"quantidade": 2.0,
_50
"valorUnitario": 22.0,
_50
"valorTotal": 44.0,
_50
"comissao": 4.0
_50
}
_50
],
_50
"valorFrete": 10.0,
_50
"valorTotalCD": 10.0
_50
}
_50
]
_50
}

[OPTIONAL] Search order documents

By exposing the GET api/v1/arquivospedido?pedidoErpId={pedidoErpId}&revendaId={revendaId} endpoint, it will be possible to query the document files related to a given order by providing the related order number.

Request format

AttributeTypeDescription
pedidoErpIdstringERP order number, which is the identification number of the order placed through the store ERP.
revendaIdintegerResale ID number.

Request body example


_10
{
_10
"pedidoErpId": "12345",
_10
"revendaId": 2
_10
}

Response format

AttributeTypeDescription
pedidoErpIdstringERP order number, which is the identification number of the order placed through the store ERP.
itensarray of objectsArray of objects containing information about each document in the order.
objectObject containing information about a document.
tipoArquivointegerType of document. SegundaViaBoleto: 0, SegundaViaTransferencia: 1, Xml: 2, Danfe: 3, NumeroDeSerie: 4, GARE: 5, GNRE: 6, Outros: 7.
descricaostringDocument description.
urlstringDocument URL.

Response body example


_10
{
_10
"pedidoErpId": "12345",
_10
"itens": [
_10
{
_10
"tipoArquivo": 0,
_10
"descricao": "Boleto",
_10
"url": "https://www.google.com/"
_10
}
_10
]
_10
}

Installing the B2B Orders app

Follow the steps below to install the B2B Orders app.

  1. Using the terminal and the VTEX IO CLI, install the B2B Orders app in the desired workspace by running vtex install vtex.omnichannel-order-status.
  2. In your browser, access your account's admin as in https://{workspace}--{account}.myvtex.com/admin. ️Remember to replace {workspace} and {account} with the workspace and account you are using.
  3. Under Account Settings, go to **Apps **> My apps.
  4. Look for the B2B Order app.
  5. Click on Settings on the B2B Order app card.
  6. Fill the following fields with the required information to communicate with the external service:
    • Link endpoint: the endpoint address of the desired service.
    • Login: access credentials of the external service.
    • Token: authentication token to access the service.
  7. Click on Save.

{"base64":"  ","img":{"width":1160,"height":733,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":19797,"url":"https://cdn.jsdelivr.net/gh/vtexdocs/dev-portal-content@main/images/querying-b2b-order-statuses-0.png"}}

Once your changes are duly saved, a new tab, named Orders B2B, will be available in your client's menu on the My Account page, as shown in the following image:

{"base64":"  ","img":{"width":1600,"height":802,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":79230,"url":"https://cdn.jsdelivr.net/gh/vtexdocs/dev-portal-content@main/images/querying-b2b-order-statuses-1.png"}}

Read our article Understanding B2B Orders for more information on the B2B Orders app.

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