Skip to main content

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.

MethodArgumentsDescription
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.

MethodArgumentsDescription
requestPasswordResetemail: stringStarts 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.

Feedback Management

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.

MethodArgumentsDescription
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.
createAddressaddressData: ObjectCreates a new address in the profile. Upon success, it invalidates the cache and forces a reload of the address list.
updateAddressid: string, addressData: ObjectUpdates the data of an existing address identified by its ID.
deleteAddressid: stringPermanently removes an address from the user's profile.

Address Cache Management

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.

MethodArgumentsDescription
fetchOrdersquery: ObjectRetrieves the list of orders placed by the customer. Supports query parameters for filtering, sorting, or pagination.
fetchSubscriptionsquery: ObjectRetrieves the list of active or past subscriptions linked to the user's profile.

Query Parameter

Example:

{
"sortBy": "createdAt",
"sortDirection": "desc",
"page": 1,
"limit": 10
}

State Integration

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.

MethodArgumentsDescription
fetchWishlist-Retrieves all saved items in the favorites. If the list is already in the global state, it returns local data for instant access.
toggleWishlistvariantId: stringAdds or removes a specific variant from favorites. The method internally handles "toggle" logic and reactively updates both the UI state and global cache.

Wishlist Characteristics
  • 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: toggleWishlist updates 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.

MethodArgumentsDescription
getMyReviewsquery: ObjectRetrieves the list of reviews written by the authenticated user. Supports filters and pagination via the query object.
createReviewvariantId: string, reviewData: ObjectSubmits a new review for a specific variant.
updateReviewreviewId: string, reviewData: ObjectModifies an existing review identified by its unique ID.
deleteReviewreviewId: stringPermanently removes a review from the system.

Feedback and State Management

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.

MethodArgumentsDescription
getCartItems-Retrieves the updated list of CartItem. Invoked automatically on access token change to ensure synchronization.
addCartIteminput: ObjectAdds a product to the cart. Requires a detailed object including skuId, priceId, quantity, and variant metadata to support proper display even for unauthenticated users.
updateCartItemitemId: string, quantity: numberModifies the quantity of an existing cart line. Automatically manages loading state and confirmation messages.
removeCartItemitemId: stringPermanently removes an item from the cart.
mergeCart-Merges the local (guest) cart into the remote account cart. Usually called immediately after login.
validatePromotionCodescodes, currency, total, skuIds, langValidates 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 }[];
}

Visual Feedback

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.

ArgumentTypeDescription
codesstring[]Array of discount codes entered by the user (Max 10).
cartTotalnumberThe current gross cart total to apply the discount on.
cartCurrencyCurrencyCodeThe cart currency (e.g., EUR, USD).
skuIdsstring[]List of SKU IDs in the cart (used to verify product-specific discounts).
langCodeLangCodeThe user's language, used for localized error messages from the validation engine.
Final Application

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.

MethodArgumentsDescription
toggleNewslettervalue: booleanUpdates 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_CUSTOMER dispatch 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 newsletter property is part of the Customer data type, ensuring persistence across sessions.
Extensibility

While currently focused on the newsletter, this API set is designed to handle future updates to other profile data (like displayName or localization preferences).