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.cart module lets you programmatically manage shopping carts that belong to individual WhatsApp Business chat sessions. A cart is tied to a specific chatId — the JID of the business you are chatting with — and persists in WhatsApp Web’s internal CartStore until it is submitted or cleared.
Carts are scoped to a specific business chat session. The
chatId you pass to every function must be the WhatsApp ID of the business contact (e.g. 5521985625689@c.us), not a group or broadcast list. A cart cannot be submitted to your own account.Reading the cart
get(wid)
Returns the current cart model for a given business chat. This is a synchronous function — it reads directly from CartStore without a network request.
The WhatsApp ID of the business chat whose cart you want to retrieve.
The cart model if a cart exists for this chat, or
undefined if none has been created yet.getThumbFromCart(wid)
Generates a base64 thumbnail image from the first item in the cart. This is the same thumbnail that appears in the order message preview when you call submit. Returns an empty string if no cart, no items, or no image is found.
The WhatsApp ID of the business chat.
A base64-encoded image string, or an empty string if a thumbnail cannot be generated.
Modifying the cart
add(chatId, products)
Adds one or more products to the cart for a business chat. Each product is fetched from the catalog using getProductById before being added, so the catalog must be accessible. If a product is already in the cart, its quantity is updated to the value you provide.
The WhatsApp ID of the business chat.
The updated cart model, or
undefined if the cart cannot be found after the update.update(chatId, productId, options)
Updates the quantity of a single product already in the cart. Internally this calls add with the new quantity, so it will also add the product if it is not yet in the cart.
The WhatsApp ID of the business chat.
The ID of the product to update.
The updated cart model.
remove(chatId, productId)
Removes a single product from the cart. The rest of the cart items are preserved.
The WhatsApp ID of the business chat.
The ID of the product to remove.
The cart model after removal.
clear(wid)
Empties all items from the cart. Throws a WPPError with code cart_not_have_products if the cart is already empty or does not exist.
The WhatsApp ID of the business chat whose cart you want to clear.
Resolves when the cart has been emptied.
Submitting the cart
submit(wid, msg?, options?)
Submits the current cart as an order message to the business chat. This creates a WhatsApp order, sends an order-type message to the conversation, and then clears the cart automatically. The returned value is the sent message object.
The WhatsApp ID of the business chat to send the order to.
An optional custom message to include with the order. If omitted, the cart’s stored message is used.
Optional send options forwarded to the underlying message sending function (e.g.
quotedMsg).The sent message object retrieved by message ID after the order is dispatched.
Full cart-to-order workflow
The following example walks through a complete purchase flow: browsing a catalog, building a cart, and submitting an order.Error codes
send_required_params
send_required_params
Thrown by
add, update, and remove when required arguments (chatId, productId, options.quantity) are missing or falsy.cart_not_have_products
cart_not_have_products
Thrown by
clear and submit when the cart does not exist or contains no items.can_not_submit_order_to_yourself
can_not_submit_order_to_yourself
Thrown by
submit when the wid matches the currently logged-in account’s own WhatsApp ID.error_send_order_request
error_send_order_request
Thrown by
submit after dispatch if the created order did not receive a valid order ID from WhatsApp’s servers.