TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/wppconnect-team/wa-js/llms.txt
Use this file to discover all available pages before exploring further.
WPP.order module gives WhatsApp Business accounts programmatic access to incoming order messages. When a customer submits a cart through WhatsApp, their order appears as a special ORDER message type in your chat. The functions in this module let you read order details, accept or decline orders, and send follow-up status updates (shipped, delivered, complete, etc.) as the fulfillment progresses.
Order messages are identified by their message ID (
msgId), not a standalone order ID. Every WPP.order function requires you to pass the ID of the order message in the chat, which you obtain from the chat’s message store or from a real-time message event.Reading an order
get(msgId)
Fetches full order details for a given order message. The message must exist in the local MsgStore and must be of type ORDER. Returns an OrderModel populated from WhatsApp’s queryOrder API.
The message ID string or
MsgKey object of the order message.msg_not_found if the message ID does not exist in the store, and msg_not_is_a_order if the message exists but is not an order type.
Accepting an order
accept(options)
Accepts an incoming order. This function performs two operations atomically:
- Updates the order message’s persistent status to
ACCEPTED(status2), which hides the “Accept Order” button in the WhatsApp UI. - Sends an interactive
ORDER_DETAILSmessage back to the customer with a “Review and pay” button.
Resolves when both the status update and the reply message have been sent successfully.
Declining an order
decline(options)
Declines an incoming order. Like accept, this performs two operations:
- Updates the order message status to
DECLINED(status3). - Sends a cancellation message to the customer showing “Canceled” status, with an optional decline note.
Resolves when the status update and the cancellation message are both sent.
Updating order status
update(options)
Sends a status update message to the customer after an order has already been accepted or declined. Use this function for lifecycle updates such as shipping, delivery, or payment confirmation.
Resolves when the status update message is sent to the customer.
Enumerations
OrderStatus
Available values for the orderStatus parameter in update.
| Value | String | Description |
|---|---|---|
OrderStatus.Pending | pending | Order is pending confirmation. |
OrderStatus.Processing | processing | Order is being processed. |
OrderStatus.PreparingToShip | preparing_to_ship | Order is being prepared for shipping. |
OrderStatus.PartiallyShipped | partially_shipped | Order has been partially shipped. |
OrderStatus.Shipped | shipped | Order has been shipped. |
OrderStatus.OutForDelivery | out_for_delivery | Order is out for delivery. |
OrderStatus.Delivered | delivered | Order has been delivered. |
OrderStatus.Complete | completed | Order is complete. |
OrderStatus.Canceled | canceled | Order has been canceled. |
OrderStatus.Delayed | delayed | Order delivery is delayed. |
OrderStatus.Failed | failed | Order has failed. |
OrderStatus.Refunded | refunded | Order has been refunded. |
OrderStatus.PaymentRequested | payment_requested | Payment has been requested from the customer. |
OrderStatus.Confirmed | confirmed | Order has been confirmed. |
PaymentStatus
Available values for the paymentStatus parameter in update.
| Value | String | Description |
|---|---|---|
PaymentStatus.Pending | pending | Payment is pending. |
PaymentStatus.Captured | captured | Payment has been captured/completed. |
PaymentStatus.Failed | failed | Payment failed. |
PaymentStatus.Canceled | canceled | Payment was canceled. |
Complete order handling workflow
The following example shows a full order lifecycle from receipt through delivery using all fourWPP.order functions.
Error codes
msg_not_found
msg_not_found
Thrown by
get, accept, decline, and update when the provided msgId does not match any message in the local MsgStore.msg_not_is_a_order
msg_not_is_a_order
Thrown by
get when the message exists but its type is not ORDER.msg_not_order
msg_not_order
Thrown by
accept, decline, and update when the message exists but its type is not ORDER.invalid_order_message
invalid_order_message
Thrown by
accept, decline, and update when the order message is missing required fields (orderId, token, chat, or sellerJid).order_not_processed
order_not_processed
Thrown by
update when the order message status is still INQUIRY (1). You must call accept or decline before sending status updates.