> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# Method name: onOrderApproved(event: OrderApprovedEvent)

# Method package: wixEcomBackend

# Method menu location: wixEcomBackend --> onOrderApproved

# Method Link: https://dev.wix.com/docs/velo/events-service-plugins/e-commerce/events/on-order-approved.md

# Method Description:

An event that triggers when an order is approved.


The `onOrderApproved()` event handler runs when an order is created and its status is updated to `"APPROVED"`. The received `OrderApprovedEvent` object contains information about the order that was approved and event metadata.

> **Note:** Backend events don't work when previewing your site.



# Method Code Examples:

*** Note: do not assume any prop names or enum values other than the ones in the example.

## An event fired when an order is approved 

```javascript
// Place this code in the events.js file
// of your site's Backend section.
// Add the file if it doesn't exist.

export function wixEcom_onOrderApproved(event) {
  const orderId = event.data.order._id;
  const orderTotalPrice = event.data.order.priceSummary.totalPrice.amount;
  const eventId = event.metadata.id;
  console.log('Order approved', event)
}


/*  Full event object:
 *
 * {
 *   "metadata": {
 *     "id": "8f0a09a4-1fd1-4ff2-976a-21f1b2e0fe2f",
 *     "entityId": "67668940-527d-4465-94c6-5475d8c7a412",
 *     "eventTime": "2022-07-31T13:42:20.141721Z",
 *     "triggeredByAnonymizeRequest": false
 *   },
 *   "data": {
 *     "order": {
 *       "_id": "67668940-527d-4465-94c6-5475d8c7a412",
 *       "number": "10124",
 *       "_createdDate": "2022-07-31T13:42:13.136Z",
 *       "_updatedDate": "2022-07-31T13:42:20.026Z",
 *       "lineItems": [
 *         {
 *           "_id": "00000000-0000-0000-0000-000000000001",
 *           "productName": {
 *             "original": "Brazilian Arabica",
 *             "translated": "Brazilian Arabica"
 *           },
 *           "catalogReference": {
 *             "catalogItemId": "0614129c-8777-9f3b-4dfe-b80a54df10d5",
 *             "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e",
 *             "options": {
 *               "options": {
 *                 "Weight": "500g",
 *                 "Ground for": "Stovetop"
 *               },
 *               "variantId": "00000000-0000-003f-0005-a316f7c67df7",
 *               "customTextFields": {
 *                 "What would you like written on the custom label?": "Enjoy our finest coffee."
 *               }
 *             }
 *           },
 *           "quantity": 1,
 *           "totalDiscount": {
 *             "amount": "0",
 *             "formattedAmount": "$0.00"
 *           },
 *           "descriptionLines": [
 *             {
 *               "name": {
 *                 "original": "Weight",
 *                 "translated": "Weight"
 *               },
 *               "plainText": {
 *                 "original": "500g",
 *                 "translated": "500g"
 *               },
 *               "lineType": "PLAIN_TEXT",
 *               "plainTextValue": {
 *                 "original": "500g",
 *                 "translated": "500g"
 *               }
 *             },
 *             {
 *               "name": {
 *                 "original": "Ground for",
 *                 "translated": "Ground for"
 *               },
 *               "plainText": {
 *                 "original": "Stovetop",
 *                 "translated": "Stovetop"
 *               },
 *               "lineType": "PLAIN_TEXT",
 *               "plainTextValue": {
 *                 "original": "Stovetop",
 *                 "translated": "Stovetop"
 *               }
 *             },
 *             {
 *               "name": {
 *                 "original": "What would you like written on the custom label?",
 *                 "translated": "What would you like written on the custom label?"
 *               },
 *               "plainText": {
 *                 "original": "Enjoy our finest coffee.",
 *                 "translated": "Enjoy our finest coffee."
 *               },
 *               "lineType": "PLAIN_TEXT",
 *               "plainTextValue": {
 *                 "original": "Enjoy our finest coffee.",
 *                 "translated": "Enjoy our finest coffee."
 *               }
 *             }
 *           ],
 *           "image": "wix:image://v1/nsplsh_306d666a306a4a74306459~mv2_d_4517_2992_s_4_2.jpg#originWidth=4517&originHeight=2992",
 *           "physicalProperties": {
 *             "weight": 0.5,
 *             "shippable": true
 *           },
 *           "itemType": {
 *             "preset": "PHYSICAL"
 *           },
 *           "fulfillerId": "85e29287-a5bf-4c25-b303-a2ddc9d975e2",
 *           "refundQuantity": 0,
 *           "price": {
 *             "amount": "48.75",
 *             "formattedAmount": "$48.75"
 *           },
 *           "priceBeforeDiscounts": {
 *             "amount": "48.75",
 *             "formattedAmount": "$48.75"
 *           },
 *           "totalPriceBeforeTax": {
 *             "amount": "48.75",
 *             "formattedAmount": "$48.75"
 *           },
 *           "totalPriceAfterTax": {
 *             "amount": "50.70",
 *             "formattedAmount": "$50.70"
 *           },
 *           "paymentOption": "FULL_PAYMENT_ONLINE",
 *           "taxDetails": {
 *             "taxableAmount": {
 *               "amount": "48.75",
 *               "formattedAmount": "$48.75"
 *             },
 *             "taxRate": "0.04",
 *             "totalTax": {
 *               "amount": "1.95",
 *               "formattedAmount": "$1.95"
 *             }
 *           }
 *         }
 *       ],
 *       "buyerInfo": {
 *         "contactId": "f61f30cd-7474-47b7-95a2-339c0fcacbd3",
 *         "email": "janedoe@gmail.com",
 *         "visitorId": "b52ec002-40dd-469c-9f9f-833988e8048d"
 *       },
 *       "paymentStatus": "PAID",
 *       "fulfillmentStatus": "NOT_FULFILLED",
 *       "buyerLanguage": "en",
 *       "weightUnit": "LB",
 *       "currency": "USD",
 *       "taxIncludedInPrices": false,
 *       "priceSummary": {
 *         "subtotal": {
 *           "amount": "48.75",
 *           "formattedAmount": "$48.75"
 *         },
 *         "shipping": {
 *           "amount": "5.0",
 *           "formattedAmount": "$5.00"
 *         },
 *         "tax": {
 *           "amount": "1.95",
 *           "formattedAmount": "$1.95"
 *         },
 *         "discount": {
 *           "amount": "0",
 *           "formattedAmount": "$0.00"
 *         },
 *         "totalPrice": {
 *           "amount": "55.70",
 *           "formattedAmount": "$55.70"
 *         },
 *         "totalWithGiftCard": {
 *           "amount": "55.70",
 *           "formattedAmount": "$55.70"
 *         },
 *         "totalWithoutGiftCard": {
 *           "amount": "55.70",
 *           "formattedAmount": "$55.70"
 *         }
 *       },
 *       "billingInfo": {
 *         "address": {
 *           "addressLine1": "525 5th Avenue",
 *           "city": "New York",
 *           "subdivision": "US-NY",
 *           "country": "US",
 *           "postalCode": "10173"
 *         },
 *         "contactDetails": {
 *           "firstName": "Jane",
 *           "lastName": "Doe",
 *           "phone": "0555555555"
 *         }
 *       },
 *       "shippingInfo": {
 *         "carrierId": "c8a08776-c095-4dec-8553-8f9698d86adc",
 *         "code": "a0fde0a4-6f4e-3716-64be-c0acbde1696a",
 *         "title": "U.S Shipping",
 *         "logistics": {
 *           "deliveryTime": "3 - 5 business days",
 *           "shippingDestination": {
 *             "address": {
 *               "addressLine1": "525 5th Avenue",
 *               "city": "New York",
 *               "subdivision": "US-NY",
 *               "country": "US",
 *               "postalCode": "10173"
 *             },
 *             "contactDetails": {
 *               "firstName": "Jane",
 *               "lastName": "Doe",
 *               "phone": "0555555555"
 *             }
 *           }
 *         },
 *         "cost": {
 *           "price": {
 *             "amount": "5",
 *             "formattedAmount": "$5.00"
 *           },
 *           "totalPriceBeforeTax": {
 *             "amount": "5",
 *             "formattedAmount": "$5.00"
 *           },
 *           "totalPriceAfterTax": {
 *             "amount": "5.0",
 *             "formattedAmount": "$5.00"
 *           },
 *           "taxDetails": {
 *             "taxRate": "0.0",
 *             "totalTax": {
 *               "amount": "0.0",
 *               "formattedAmount": "$0.00"
 *             }
 *           },
 *           "discount": {
 *             "amount": "0",
 *             "formattedAmount": "$0.00"
 *           }
 *         },
 *         "region": {
 *           "name": "Region 3"
 *         }
 *       },
 *       "buyerNote": "This is a buyerNote",
 *       "status": "APPROVED",
 *       "archived": false,
 *       "taxSummary": {
 *         "totalTax": {
 *           "amount": "1.95",
 *           "formattedAmount": "$1.95"
 *         },
 *         "manualTaxRate": "0.04"
 *       },
 *       "appliedDiscounts": [],
 *       "activities": [
 *         {
 *           "_createdDate": "2022-07-31T13:42:13.136Z",
 *           "type": "ORDER_PLACED"
 *         }
 *       ],
 *       "attributionSource": "UNSPECIFIED",
 *       "createdBy": {
 *         "visitorId": "b52ec002-40dd-469c-9f9f-833988e8048d"
 *       },
 *       "channelInfo": {
 *         "type": "WEB"
 *       },
 *       "seenByAHuman": false,
 *       "checkoutId": "62d01935-e0d3-4063-9e78-da099462e90c",
 *       "customFields": [],
 *       "cartId": "52fec024-4379-4a96-9237-9660030be6fe",
 *       "payNow": {
 *         "subtotal": {
 *           "amount": "48.75",
 *           "formattedAmount": "$48.75"
 *         },
 *         "shipping": {
 *           "amount": "5.0",
 *           "formattedAmount": "$5.00"
 *         },
 *         "tax": {
 *           "amount": "1.95",
 *           "formattedAmount": "$1.95"
 *         },
 *         "discount": {
 *           "amount": "0",
 *           "formattedAmount": "$0.00"
 *         },
 *         "totalPrice": {
 *           "amount": "55.70",
 *           "formattedAmount": "$55.70"
 *         },
 *         "totalWithGiftCard": {
 *           "amount": "55.70",
 *           "formattedAmount": "$55.70"
 *         },
 *         "totalWithoutGiftCard": {
 *           "amount": "55.70",
 *           "formattedAmount": "$55.70"
 *         }
 *       },
 *       "balanceSummary": {
 *         "balance": {
 *           "amount": "0.0",
 *           "formattedAmount": "$0.00"
 *         }
 *       }
 *     }
 *   }
 * }
 *
 */
```

---