NPM Package
@commercengine/checkout
Vue integration for Commerce Engine Checkout.
Installation
Setup
CallinitCheckout once at your app’s entry point:
main.ts
Use the composable
useCheckout() returns reactive refs and action methods. Call it inside setup() or <script setup>.
CartButton.vue
Full example
App.vue
Nuxt
For Nuxt 3, create a plugin to initialize checkout:plugins/checkout.client.ts
.client.ts suffix ensures this only runs in the browser. Then use useCheckout() in any component.
Syncing external auth
AuthSync.vue
Composable API reference
useCheckout() returns:
| Property | Type | Description |
|---|---|---|
isReady | Readonly<Ref<boolean>> | true when the checkout iframe is loaded |
isOpen | Readonly<Ref<boolean>> | true when the overlay is visible |
cartCount | Readonly<Ref<number>> | Number of items in the cart |
cartTotal | Readonly<Ref<number>> | Cart subtotal |
cartCurrency | Readonly<Ref<string>> | Currency code |
isLoggedIn | Readonly<Ref<boolean>> | Whether a user is logged in |
user | Readonly<Ref<UserInfo | null>> | Current user info |
openCart() | function | Open the cart drawer |
openCheckout() | function | Open checkout directly |
close() | function | Close the overlay |
addToCart(productId, variantId, quantity?) | function | Add an item to the cart |
updateTokens(accessToken, refreshToken?) | function | Sync auth tokens |