Returns
Promise<ShopifyCustomer> - The customer object with profile data.
Throws
Error- If not logged in or token is invalid.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Get the current customer profile
openbridge.customer.get()
Promise<ShopifyCustomer> - The customer object with profile data.
Error - If not logged in or token is invalid.try {
const customer = await openbridge.customer.get()
console.log(customer.email)
console.log(customer.firstName, customer.lastName)
console.log(`Total orders: ${customer.numberOfOrders}`)
} catch (error) {
console.error('Not logged in')
}
async function loadAccountPage() {
const customer = await openbridge.customer.get()
document.querySelector('#name').textContent = customer.displayName
document.querySelector('#email').textContent = customer.email
document.querySelector('#phone').textContent = customer.phone || 'Not set'
if (customer.defaultAddress) {
document.querySelector('#address').textContent =
customer.defaultAddress.formatted.join(', ')
}
}
// Async - fetches fresh data from Shopify
const customer = await openbridge.customer.get()
// Sync - returns cached data (may be stale)
const cachedCustomer = openbridge.customer.getCached()
// Check login state without API call
const isLoggedIn = openbridge.customer.isLoggedIn()
| Method | Description |
|---|---|
.getCached() | Get cached customer data synchronously |
.isLoggedIn() | Check if customer is logged in (sync) |
.getToken() | Get the raw access token |