WrCustomer
webround-docs / WrCustomer
Interface: WrCustomer
Defined in: wr.d.ts:931
The customer context — provides authentication state, cart, wishlist, addresses, orders, reviews, and all related actions.
Available as wr.customer in every custom component.
Example
const { profile, isLoggedIn, cart } = wr.customer;
if (!isLoggedIn) await wr.customer.login({ email, password });
Properties
awaiting2FAChallenge
awaiting2FAChallenge:
object
Defined in: wr.d.ts:952
Data needed to complete a pending 2FA challenge
challengeId
challengeId:
string
deviceId
deviceId:
string
email
email:
string
cart
cart:
WrCart
Defined in: wr.d.ts:941
The customer's current cart
cartError
cartError:
string
Defined in: wr.d.ts:956
Last cart error message, if any
error
error:
string
Defined in: wr.d.ts:939
Last auth error message, if any
isLoading
isLoading:
boolean
Defined in: wr.d.ts:937
Whether any auth operation is in progress
isLoadingCart
isLoadingCart:
boolean
Defined in: wr.d.ts:954
Whether the cart is currently loading
isLoggedIn
isLoggedIn:
boolean
Defined in: wr.d.ts:935
Whether the customer is currently authenticated
profile
profile:
WrCustomerProfile
Defined in: wr.d.ts:933
The authenticated customer's profile, or null if not logged in
step
step:
"idle"|"signingUp"|"loggingIn"|"loggedIn"|"require2FA"|"requestingReset"|"settingUp2FA"|"verifying2FA"|"deletingAccount"
Defined in: wr.d.ts:950
Current auth flow step.
idle— no operation in progressrequire2FA— waiting for 2FA code after loginloggedIn— authenticated
wishlist
wishlist:
WrWishlistItem[]
Defined in: wr.d.ts:943
The customer's wishlist items
Methods
addCartItem()
addCartItem(
input):Promise<void>
Defined in: wr.d.ts:1080
Add a variant to the cart.
Parameters
input
Returns
Promise<void>
Example
await wr.customer.addCartItem({
variantId, priceId, quantity: 1,
variantName, variantSlug, coverUrl,
variantOptions: [], currentPrice
})
confirm2FA()
confirm2FA(
data):Promise<{success:true; }>
Defined in: wr.d.ts:1007
Complete a pending 2FA login challenge.
Parameters
data
challengeId
string
code
string
email
string
Returns
Promise<{ success: true; }>
Example
await wr.customer.confirm2FA({ email, code, challengeId })
createAddress()
createAddress(
data):Promise<WrAddress>
Defined in: wr.d.ts:1025
Save a new address for the customer.
Parameters
data
Omit<WrAddress, "id">
Returns
Promise<WrAddress>
createReview()
createReview(
variantId,data):Promise<WrReviewByCustomerItem>
Defined in: wr.d.ts:1055
Submit a review for a variant.
Parameters
variantId
string
data
comment?
string
rating
number
title?
string
Returns
Promise<WrReviewByCustomerItem>
deleteAddress()
deleteAddress(
addressId):Promise<void>
Defined in: wr.d.ts:1031
Delete an address by ID.
Parameters
addressId
string
Returns
Promise<void>
deleteReview()
deleteReview(
reviewId):Promise<void>
Defined in: wr.d.ts:1061
Delete a review by ID.
Parameters
reviewId
string
Returns
Promise<void>
fetchOrders()
fetchOrders(
query?):Promise<void| {data:WrOrder[];pagination:WrPagination; }>
Defined in: wr.d.ts:1037
Fetch the customer's order history.
Parameters
query?
Returns
Promise<void | { data: WrOrder[]; pagination: WrPagination; }>
Example
const { data, pagination } = await wr.customer.fetchOrders({ page: 1, limit: 10 })
fetchSubscriptions()
fetchSubscriptions(
query?):Promise<void| {data:WrSubscription[];pagination:WrPagination; }>
Defined in: wr.d.ts:1040
Fetch the customer's active subscriptions.
Parameters
query?
Returns
Promise<void | { data: WrSubscription[]; pagination: WrPagination; }>
fetchWishlist()
fetchWishlist():
Promise<{data:WrWishlistItem[];total:number; }>
Defined in: wr.d.ts:1043
Fetch the customer's wishlist.
Returns
Promise<{ data: WrWishlistItem[]; total: number; }>
getAddresses()
getAddresses():
Promise<WrAddress[]>
Defined in: wr.d.ts:1022
Fetch all addresses saved by the customer.
Returns
Promise<WrAddress[]>
getCartItems()
getCartItems():
Promise<WrCart>
Defined in: wr.d.ts:1067
Fetch and sync the current cart. Guest cart from localStorage, authenticated cart from the API.
Returns
Promise<WrCart>
getMyReviews()
getMyReviews(
query?):Promise<{data:WrReviewByCustomerItem[];pagination:WrPagination; }>
Defined in: wr.d.ts:1052
Fetch all reviews written by the current customer.
Parameters
query?
Returns
Promise<{ data: WrReviewByCustomerItem[]; pagination: WrPagination; }>
invalidateAndReloadCart()
invalidateAndReloadCart():
Promise<void>
Defined in: wr.d.ts:1095
Force a full cart reload from the server, bypassing cache.
Returns
Promise<void>
login()
login(
data):Promise<{success:true; } | {requires2FA:true; }>
Defined in: wr.d.ts:977
Log in with email and password.
Returns { requires2FA: true } if the account has 2FA enabled.
Parameters
data
email
string
password
string
platform?
string
region?
string
Returns
Promise<{ success: true; } | { requires2FA: true; }>
Example
const result = await wr.customer.login({ email, password });
if ('requires2FA' in result) { // show 2FA input }
logout()
logout():
Promise<void>
Defined in: wr.d.ts:980
Log out the current customer.
Returns
Promise<void>
mergeCart()
mergeCart():
Promise<void>
Defined in: wr.d.ts:1092
Merge the guest cart into the authenticated customer's cart after login. Called automatically on login.
Returns
Promise<void>
refreshAccessToken()
refreshAccessToken():
Promise<{customer:WrCustomerProfile;exp:number;token:string; }>
Defined in: wr.d.ts:986
Silently refresh the access token using the stored refresh token. Called automatically by the SDK — you rarely need this directly.
Returns
Promise<{ customer: WrCustomerProfile; exp: number; token: string; }>
removeCartItem()
removeCartItem(
itemId):Promise<void>
Defined in: wr.d.ts:1086
Remove an item from the cart.
Parameters
itemId
string
Returns
Promise<void>
request2FASetup()
request2FASetup():
Promise<any>
Defined in: wr.d.ts:1001
Initiate 2FA setup. Returns a QR code URL or secret to display to the user.
Returns
Promise<any>
Example
const setup = await wr.customer.request2FASetup()
requestAccountDeletion()
requestAccountDeletion():
Promise<void>
Defined in: wr.d.ts:1010
Request deletion of the customer's account.
Returns
Promise<void>
requestPasswordReset()
requestPasswordReset(
Promise<void>
Defined in: wr.d.ts:992
Send a password reset email.
Parameters
email
string
Returns
Promise<void>
Example
wr.customer.requestPasswordReset('[email protected]')
requestResendEmailVerification()
requestResendEmailVerification():
Promise<void>
Defined in: wr.d.ts:995
Resend the email verification link to the logged-in customer.
Returns
Promise<void>
setActiveAccountSection()
setActiveAccountSection(
section):void
Defined in: wr.d.ts:1113
Navigate to a specific section of the account page.
Parameters
section
string
Returns
void
Example
wr.customer.setActiveAccountSection('orders')
signup()
signup(
data):Promise<boolean>
Defined in: wr.d.ts:966
Register a new customer account.
Parameters
data
confirmPassword
string
displayName
string
email
string
password
string
platform?
string
region?
string
Returns
Promise<boolean>
true on success
Example
await wr.customer.signup({ email, password, confirmPassword, displayName })
subscribeNewsletter()
subscribeNewsletter(
Promise<{direct:boolean;success:boolean; }>
Defined in: wr.d.ts:1016
Subscribe an email address to the store newsletter.
Parameters
email
string
Returns
Promise<{ direct: boolean; success: boolean; }>
{ direct: true } if immediate, false if requires email confirmation
toggleWishlist()
toggleWishlist(
variantId):Promise<{item?:WrWishlistItem;success:boolean;wasAdded:boolean; }>
Defined in: wr.d.ts:1049
Add or remove a variant from the wishlist.
Parameters
variantId
string
Returns
Promise<{ item?: WrWishlistItem; success: boolean; wasAdded: boolean; }>
{ wasAdded: true } if added, { wasAdded: false } if removed
unsubscribeNewsletter()
unsubscribeNewsletter(
Promise<{direct:boolean;success:boolean; }>
Defined in: wr.d.ts:1019
Unsubscribe an email address from the store newsletter.
Parameters
email
string
Returns
Promise<{ direct: boolean; success: boolean; }>
updateAddress()
updateAddress(
addressId,data):Promise<WrAddress>
Defined in: wr.d.ts:1028
Update an existing address.
Parameters
addressId
string
data
Partial<WrAddress>
Returns
Promise<WrAddress>
updateCartItem()
updateCartItem(
itemId,quantity):Promise<void>
Defined in: wr.d.ts:1083
Update the quantity of a cart item.
Parameters
itemId
string
quantity
number
Returns
Promise<void>
updateReview()
updateReview(
reviewId,data):Promise<WrReviewByCustomerItem>
Defined in: wr.d.ts:1058
Update an existing review.
Parameters
reviewId
string
data
comment?
string
rating?
number
title?
string
Returns
Promise<WrReviewByCustomerItem>
validatePromotionCodes()
validatePromotionCodes(
codes,currencyCode,cartTotalGross,variantIds,selectedLang):Promise<WrCartVerifyCodesResponse>
Defined in: wr.d.ts:1107
Validate one or more coupon/promotion codes against the current cart.
Parameters
codes
string[]
currencyCode
string
cartTotalGross
number
variantIds
string[]
selectedLang
string
Returns
Promise<WrCartVerifyCodesResponse>
Example
const result = await wr.customer.validatePromotionCodes(
['SUMMER20'], 'EUR', cartTotalGross, variantIds, 'en'
)
if (result?.valid) { // apply discount }