Purchase orders (B2B)
When B2B for Adobe Commerce is installed and purchase orders are activated for a company account, all orders are automatically created as purchase orders. Company users with the required permissions can create, edit, and delete their own purchase orders as well as those created by subordinate users.
Adobe Commerce provides multiple mutations that define and manage purchase orders. However, there are no top-level queries that return lists of purchase orders or purchase order details.
The customer
query now returns details about purchase orders.
See Purchase Orders for Companies in the B2B for Adobe Commerce Guide for information about enabling the B2B purchase order capabilities and the different workflows for online and offline payment methods.
The following examples demonstrate customer
queries that return information about purchase orders.
All examples require a valid customer authentication token.
Return a list of purchase orders
The following example returns the list of purchase orders.
Request:
Copied to your clipboard{customer {purchase_orders(currentPage: 1,pageSize: 20,filter: {company_purchase_orders: true,}) {total_countpage_info {current_pagepage_sizetotal_pages}items {uidnumberorder {id}created_atupdated_atcreated_by {firstnamelastname}statusorder {total {grand_total {valuecurrency}}}}}}}
Response:
Copied to your clipboard{"data": {"customer": {"purchase_orders": {"total_count": 2,"page_info": {"current_page": 1,"page_size": 20,"total_pages": 1},"items": [{"uid": "Nw==","number": "000000007","order": null,"created_at": "2023-01-25 20:59:05","updated_at": "2023-01-25 21:10:31","created_by": {"firstname": "Melanie","lastname": "Shaw"},"status": "APPROVED"},{"uid": "Ng==","number": "000000006","order": {"id": "NQ==","total": {"grand_total": {"value": 375,"currency": "USD"}}},"created_at": "2023-01-25 20:35:56","updated_at": "2023-01-31 19:45:09","created_by": {"firstname": "Kevin","lastname": "Harper"},"status": "ORDER_PLACED"}]}}}}
Return details about one purchase order
The following example returns the purchase order information.
Request:
Copied to your clipboard{customer {purchase_order(uid: "MQ==") {uidnumbercreated_atupdated_atstatusavailable_actionscreated_by {firstnamelastname}order {number}comments {created_attextauthor {firstnamelastname}}history_log {activitycreated_at}quote {items {product {sku}}prices {grand_total {valuecurrency}}}}}}
Response:
Copied to your clipboard{"data": {"customer": {"purchase_order": {"uid": "MQ==","number": "000000001","created_at": "2023-01-10 18:32:13","updated_at": "2023-01-10 18:32:13","status": "APPROVED","available_actions": ["PLACE_ORDER"],"created_by": {"firstname": "John","lastname": "Doe","email": "john.doe@example.com"},"order": null,"comments": [],"history_log": [],"quote": {"items": [{"product": {"sku": "Simple product"}}],"prices": {"grand_total": {"value": 14,"currency": "USD"}}}}}}}
Check if the customer is enabled for purchase orders
The following example returns true
if the customer has the purchase order functionality enabled.
Request:
Copied to your clipboard{customer {purchase_orders_enabled}}
Response:
Copied to your clipboard{"data": {"customer": {"purchase_orders_enabled": true}}}