wr.customer Utilities (Auth & Account)
These methods are available via the wr.customer prop and allow you to manage the entire user lifecycle: from authentication and account security to personal data management.
Authentication and Session
These methods manage login, registration, and user session maintenance.
| Method | Arguments | Description |
|---|---|---|
| login | { email, password, platform, region? } | Performs the login. If the user has 2FA active, it returns a requires2FA flag and updates the state to display the verification code module. |
| signup | { email, password, confirmPassword, displayName, platform, region? } | Registers a new account. Automatically sends a verification email to the provided address. |
| logout | - | Terminates the current session, removes security tokens, and resets the customer state. |
| refreshAccessToken | - | Renews the access token using the deviceId. Usually invoked in the background to keep the session active. |
Security and Account Recovery
Methods dedicated to account protection and credential management.
| Method | Arguments | Description |
|---|---|---|
| requestPasswordReset | email: string | Starts the password recovery procedure by sending a secure link to the user. |
| requestResendEmailVerification | - | Resends the confirmation email to activate the account. |
| request2FASetup | - | Starts the two-factor authentication setup, returning the secret or QR code. |
| confirm2FA | { email, code, challengeId } | Verifies the OTP code provided by the user to complete login or security setup. |
| requestAccountDeletion | - | Sends a formal request to delete the account and all associated data. |
All wr.customer utilities integrate an automatic notification system (Toast) that informs the user of the operation's outcome, using the translations (locale) configured in the system for success or error messages.
Address Management
These utilities allow managing the set of addresses (shipping and billing) saved in the user's profile. The system automatically handles cache invalidation to ensure the list is always up-to-date after every change.
| Method | Arguments | Description |
|---|---|---|
| getAddresses | - | Retrieves the user's full address list. If data is already in the local cache (customer_addresses_list), it returns the saved version to optimize performance. |
| createAddress | addressData: Object | Creates a new address in the profile. Upon success, it invalidates the cache and forces a reload of the address list. |
| updateAddress | id: string, addressData: Object | Updates the data of an existing address identified by its ID. |
| deleteAddress | id: string | Permanently removes an address from the user's profile. |
The create, update, and delete functions internally invoke clearAddressListCache. This ensures that any component using getAddresses or listening to the address state immediately receives updated data without manual developer intervention.
Orders and Subscriptions
These methods allow retrieving the purchase history and the status of recurring services (subscriptions) associated with the user's account.
| Method | Arguments | Description |
|---|---|---|
| fetchOrders | query: Object | Retrieves the list of orders placed by the customer. Supports query parameters for filtering, sorting, or pagination. |
| fetchSubscriptions | query: Object | Retrieves the list of active or past subscriptions linked to the user's profile. |
Query Parameter
Example:
{
"sortBy": "createdAt",
"sortDirection": "desc",
"page": 1,
"limit": 10
}
Both methods automatically update the global state for orders and subscriptions. In case of retrieval errors (e.g., expired session), the system autonomously handles redirection or user notification via configured localization messages.
Wishlist (Favorites)
These utilities manage the user's wishlist. The wishlist in webround.com is designed to be fast and always synchronized; therefore, it is not paginated and has a maximum limit of 50 items.
| Method | Arguments | Description |
|---|---|---|
| fetchWishlist | - | Retrieves all saved items in the favorites. If the list is already in the global state, it returns local data for instant access. |
| toggleWishlist | variantId: string | Adds or removes a specific variant from favorites. The method internally handles "toggle" logic and reactively updates both the UI state and global cache. |
- Item Limit: The wishlist can contain a maximum of 50 items. Once reached, an item must be removed before adding a new one.
- No Pagination: Since the data volume is limited, the list is always returned in its entirety to simplify display in components like sliders or dedicated grids.
- Cache Sync:
toggleWishlistupdates the cache in the background, ensuring the visual feedback for the user is correctly synchronized with the user view.
Reviews
These utilities allow the user to manage feedback on purchased products. Reviews are linked to specific product variants and support creation, modification, and removal operations.
| Method | Arguments | Description |
|---|---|---|
| getMyReviews | query: Object | Retrieves the list of reviews written by the authenticated user. Supports filters and pagination via the query object. |
| createReview | variantId: string, reviewData: Object | Submits a new review for a specific variant. |
| updateReview | reviewId: string, reviewData: Object | Modifies an existing review identified by its unique ID. |
| deleteReview | reviewId: string | Permanently removes a review from the system. |
Every operation automatically updates the global reviews state (REVIEW_LIST). After each action, the system displays a confirmation Toast using the store's localization keys.
Cart Management
These utilities allow manipulating the user's cart. The system internally uses a useCartStrategy that autonomously decides whether to operate locally (for guest users) or remotely (for authenticated users), ensuring data persistence.
| Method | Arguments | Description |
|---|---|---|
| getCartItems | - | Retrieves the updated list of CartItem. Invoked automatically on access token change to ensure synchronization. |
| addCartItem | input: Object | Adds a product to the cart. Requires a detailed object including skuId, priceId, quantity, and variant metadata to support proper display even for unauthenticated users. |
| updateCartItem | itemId: string, quantity: number | Modifies the quantity of an existing cart line. Automatically manages loading state and confirmation messages. |
| removeCartItem | itemId: string | Permanently removes an item from the cart. |
| mergeCart | - | Merges the local (guest) cart into the remote account cart. Usually called immediately after login. |
| validatePromotionCodes | codes, currency, total, skuIds, lang | Validates an array of promo codes against the current cart content and selected currency. |
| invalidateAndReloadCart | - | Forces a full cart reload from the server to update prices, discounts, and availability. |
addCartItem Input Detail
To ensure a reactive UI and correct operation even for authenticated users, the addCartItem method requires variant metadata. This allows the cart to show the added item instantly without waiting for a new server fetch. Unauthenticated users do not have server-side cart storage; instead, everything is loaded locally and communicates with APIs only for changes or availability checks.
{
skuId: string;
priceId: string;
quantity: number;
variantName: string;
variantSlug: string;
coverUrl: string;
variantOptions: { optionName: string, optionValue: string }[];
}
All cart methods (except mergeCart) automatically trigger loading and success Toasts. Messages are pulled directly from the locale object of the SiteContext.
validatePromotionCodes Input Detail
The validatePromotionCodes method analyzes the applicability of one or more coupons based on the current shopping session.
| Argument | Type | Description |
|---|---|---|
| codes | string[] | Array of discount codes entered by the user (Max 10). |
| cartTotal | number | The current gross cart total to apply the discount on. |
| cartCurrency | CurrencyCode | The cart currency (e.g., EUR, USD). |
| skuIds | string[] | List of SKU IDs in the cart (used to verify product-specific discounts). |
| langCode | LangCode | The user's language, used for localized error messages from the validation engine. |
Validation via this method confirms code applicability and provides immediate feedback. However, the definitive economic application of savings always occurs on the server during the final checkout phase to ensure maximum security. This method is for display purposes only.
Preferences and Personal Data
These utilities manage profile settings and authenticated user consents.
| Method | Arguments | Description |
|---|---|---|
| toggleNewsletter | value: boolean | Updates the newsletter subscription status. Synchronizes the new value with the server and immediately updates the customer object in the global state. |
State and Feedback Management
The toggleNewsletter method is optimized for immediate feedback and data consistency:
- Reactive Update: After the server call, a
SET_CUSTOMERdispatch is executed, ensuring any UI component (like toggles or checkboxes) instantly reflects the choice. - Localized Messaging: Uses specific keys (
newsletterSubscribed/newsletterUnsubscribed) for success Toasts. - Profile Integration: The
newsletterproperty is part of the Customer data type, ensuring persistence across sessions.
While currently focused on the newsletter, this API set is designed to handle future updates to other profile data (like displayName or localization preferences).