Search...
onCheckoutUpdated( )
An event that triggers when a checkout is updated. A checkout is updated when, for example, items are added or a coupon is removed.
Description
The onCheckoutUpdated()
event handler runs when a new checkout is updated. The received CheckoutUpdated
object contains information about the checkout that was updated and event metadata.
Note: Backend events don't work when previewing your site.
Syntax
function wixEcom_onCheckoutUpdated(event: CheckoutUpdated): void
onCheckoutUpdated Parameters
NAME
TYPE
DESCRIPTION
event
Optional
CheckoutUpdated
Information about the checkout that was updated and event metadata.
Returns
This function does not return anything.
Return Type:
void
Was this helpful?
An event fired when a checkout is updated
Copy Code
1// Place this code in the events.js file2// of your site's Backend section.3// Add the file if it doesn't exist.45export function wixEcom_onCheckoutUpdated(event) {6 const checkoutSubtotal = event.entity.subtotal.amount;7 const checkoutId = event.entity._id;8 const eventId = event.metadata.id;9 console.log('Checkout updated', event)10}1112/* Full event object:13 *14 * {15 * "metadata": {16 * "id": "e508b5f9-a7d2-4b37-94ce-2b7767cfa49c",17 * "entityId": "81b73bc6-d403-4afe-8464-226f9505b1c2",18 * "eventTime": "2022-10-27T11:42:17.211724Z",19 * "triggeredByAnonymizeRequest": false20 * },21 * "entity": {22 * "_id": "81b73bc6-d403-4afe-8464-226f9505b1c2",23 * "lineItems": [24 * {25 * "_id": "00000000-0000-0000-0000-000000000001",26 * "quantity": 3,27 * "catalogReference": {28 * "catalogItemId": "c8539b66-7a44-fe18-affc-afec4be8562a",29 * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e"30 * },31 * "productName": {32 * "original": "Shirt",33 * "translated": "Shirt"34 * },35 * "url": "https://example.wixsite.com",36 * "price": {37 * "amount": "10",38 * "convertedAmount": "10",39 * "formattedAmount": "$10.00",40 * "formattedConvertedAmount": "$10.00"41 * },42 * "lineItemPrice": {43 * "amount": "30",44 * "convertedAmount": "30",45 * "formattedAmount": "$30.00",46 * "formattedConvertedAmount": "$30.00"47 * },48 * "fullPrice": {49 * "amount": "10",50 * "convertedAmount": "10",51 * "formattedAmount": "$10.00",52 * "formattedConvertedAmount": "$10.00"53 * },54 * "priceBeforeDiscounts": {55 * "amount": "10",56 * "convertedAmount": "10",57 * "formattedAmount": "$10.00",58 * "formattedConvertedAmount": "$10.00"59 * },60 * "totalPriceAfterTax": {61 * "amount": "20",62 * "convertedAmount": "20",63 * "formattedAmount": "$20.00",64 * "formattedConvertedAmount": "$20.00"65 * },66 * "totalPriceBeforeTax": {67 * "amount": "20",68 * "convertedAmount": "20",69 * "formattedAmount": "$20.00",70 * "formattedConvertedAmount": "$20.00"71 * },72 * "taxDetails": {73 * "taxableAmount": {74 * "amount": "20",75 * "convertedAmount": "20",76 * "formattedAmount": "$20.00",77 * "formattedConvertedAmount": "$20.00"78 * },79 * "taxRate": "0",80 * "totalTax": {81 * "amount": "0",82 * "convertedAmount": "0",83 * "formattedAmount": "$0.00",84 * "formattedConvertedAmount": "$0.00"85 * },86 * "rateBreakdown": []87 * },88 * "discount": {89 * "amount": "10",90 * "convertedAmount": "10",91 * "formattedAmount": "$10.00",92 * "formattedConvertedAmount": "$10.00"93 * },94 * "descriptionLines": [],95 * "media": "wix:image://v1/3c76e2_c5331f937348492a97df87b0a3b34ea4~mv2.jpg#originWidth=1000&originHeight=1000",96 * "availability": {97 * "status": "AVAILABLE"98 * },99 * "physicalProperties": {100 * "sku": "364115376135191",101 * "shippable": true102 * },103 * "couponScopes": [104 * {105 * "namespace": "stores",106 * "group": {107 * "name": "collection",108 * "entityId": "00000000-000000-000000-000000000001"109 * }110 * },111 * {112 * "namespace": "stores",113 * "group": {114 * "name": "product",115 * "entityId": "c8539b66-7a44-fe18-affc-afec4be8562a"116 * }117 * }118 * ],119 * "itemType": {120 * "preset": "PHYSICAL"121 * },122 * "paymentOption": "FULL_PAYMENT_ONLINE",123 * "rootCatalogItemId": "c8539b66-7a44-fe18-affc-afec4be8562a"124 * }125 * ],126 * "shippingInfo": {127 * "carrierServiceOptions": []128 * },129 * "buyerInfo": {130 * "contactId": "f7dc17a6-825a-466e-a78e-c4abea0217db",131 * "memberId": "c43190d2-eea3-493e-b6e8-f146850c6873"132 * },133 * "conversionCurrency": "USD",134 * "priceSummary": {135 * "subtotal": {136 * "amount": "30",137 * "convertedAmount": "30",138 * "formattedAmount": "$30.00",139 * "formattedConvertedAmount": "$30.00"140 * },141 * "shipping": {142 * "amount": "0",143 * "convertedAmount": "0",144 * "formattedAmount": "$0.00",145 * "formattedConvertedAmount": "$0.00"146 * },147 * "tax": {148 * "amount": "0",149 * "convertedAmount": "0",150 * "formattedAmount": "$0.00",151 * "formattedConvertedAmount": "$0.00"152 * },153 * "discount": {154 * "amount": "10",155 * "convertedAmount": "10",156 * "formattedAmount": "$10.00",157 * "formattedConvertedAmount": "$10.00"158 * },159 * "total": {160 * "amount": "20",161 * "convertedAmount": "20",162 * "formattedAmount": "$20.00",163 * "formattedConvertedAmount": "$20.00"164 * },165 * "additionalFees": {166 * "amount": "0",167 * "convertedAmount": "0",168 * "formattedAmount": "$0.00",169 * "formattedConvertedAmount": "$0.00"170 * }171 * },172 * "calculationErrors": {173 * "orderValidationErrors": []174 * },175 * "appliedDiscounts": [176 * {177 * "discountType": "GLOBAL",178 * "lineItemIds": [],179 * "coupon": {180 * "_id": "fbb94b06-7447-4161-9c48-59bfcdc39e77",181 * "code": "SUMMERSALE10",182 * "amount": {183 * "amount": "10",184 * "convertedAmount": "10",185 * "formattedAmount": "$10.00",186 * "formattedConvertedAmount": "$10.00"187 * },188 * "name": "SUMMERSALE10",189 * "couponType": "MoneyOff"190 * }191 * }192 * ],193 * "customFields": [],194 * "weightUnit": "KG",195 * "currency": "USD",196 * "channelType": "WEB",197 * "siteLanguage": "en",198 * "buyerLanguage": "en",199 * "completed": false,200 * "taxIncludedInPrice": false,201 * "createdBy": {202 * "memberId": "c43190d2-eea3-493e-b6e8-f146850c6873"203 * },204 * "_createdDate": "2022-10-27T11:42:17.059Z",205 * "_updatedDate": "2022-10-27T11:42:17.201Z",206 * "payNow": {207 * "subtotal": {208 * "amount": "30",209 * "convertedAmount": "30",210 * "formattedAmount": "$30.00",211 * "formattedConvertedAmount": "$30.00"212 * },213 * "shipping": {214 * "amount": "0",215 * "convertedAmount": "0",216 * "formattedAmount": "$0.00",217 * "formattedConvertedAmount": "$0.00"218 * },219 * "tax": {220 * "amount": "0",221 * "convertedAmount": "0",222 * "formattedAmount": "$0.00",223 * "formattedConvertedAmount": "$0.00"224 * },225 * "discount": {226 * "amount": "10",227 * "convertedAmount": "10",228 * "formattedAmount": "$10.00",229 * "formattedConvertedAmount": "$10.00"230 * },231 * "total": {232 * "amount": "20",233 * "convertedAmount": "20",234 * "formattedAmount": "$20.00",235 * "formattedConvertedAmount": "$20.00"236 * },237 * "additionalFees": {238 * "amount": "0",239 * "convertedAmount": "0",240 * "formattedAmount": "$0.00",241 * "formattedConvertedAmount": "$0.00"242 * }243 * },244 * "payLater": {245 * "subtotal": {246 * "amount": "0",247 * "convertedAmount": "0",248 * "formattedAmount": "$0.00",249 * "formattedConvertedAmount": "$0.00"250 * },251 * "shipping": {252 * "amount": "0",253 * "convertedAmount": "0",254 * "formattedAmount": "$0.00",255 * "formattedConvertedAmount": "$0.00"256 * },257 * "tax": {258 * "amount": "0",259 * "convertedAmount": "0",260 * "formattedAmount": "$0.00",261 * "formattedConvertedAmount": "$0.00"262 * },263 * "discount": {264 * "amount": "0",265 * "convertedAmount": "0",266 * "formattedAmount": "$0.00",267 * "formattedConvertedAmount": "$0.00"268 * },269 * "total": {270 * "amount": "0",271 * "convertedAmount": "0",272 * "formattedAmount": "$0.00",273 * "formattedConvertedAmount": "$0.00"274 * },275 * "additionalFees": {276 * "amount": "0",277 * "convertedAmount": "0",278 * "formattedAmount": "$0.00",279 * "formattedConvertedAmount": "$0.00"280 * }281 * },282 * "membershipOptions": {283 * "eligibleMemberships": [],284 * "invalidMemberships": [],285 * "selectedMemberships": {286 * "memberships": []287 * }288 * },289 * "additionalFees": []290 * }291 * }292 *293 */