wr.cart Utilities
The wr.cart object (accessible via the global component context of webround.com) exposes all the properties and methods necessary to manage checkout, shipping preferences, and total calculations.
This interface serves as the command center for transforming a simple cart into an order ready for payment.
Cart State
These properties track user selections and economic calculations during the final stages of the purchase. They are located within wr.cart.state.
| Property | Type | Description |
|---|---|---|
| deliverySelections | Record<string, DeliveryMethod> | Map associating each SKU ID in the cart with the chosen delivery method (shipping, pickup, digital, none). |
| customerEmail | string | The user's email for contact or guest checkout. |
| selectedShippingAddress | ShippingAddress | The address entered by the customer for shipping. |
| selectedBillingAddress | ShippingAddress | The address entered by the customer for billing. |
| useBillingAsShipping | boolean | Flag to use the billing address for shipping. |
| orderDeliveryMethod | string (UUID) | The ID of the shipping method chosen for the order. (Found in wr.cart.state.shipping under the methodId property.) |
| cartTotalNet | number | Net total of the cart (taxable). |
| cartTotalGross | number | Final gross total (inclusive of VAT and shipping). |
| shipping | Shipping | Calculated object containing compatible methods and dynamic costs. |
| validatedCoupons | Coupon[] | List of applied and validated coupons. |
Methods: Delivery Management
| Method | Arguments | Description |
|---|---|---|
| setDeliveryMethod | itemId: string, method: DeliveryMethod | Sets the delivery mode for a single item in the cart. |
| setOrderDeliveryMethod | methodId: string | Sets the global shipping method for the entire order. |
| clearElement | itemId: string | Removes the delivery selections made for a specific item. |
Methods: Addresses and Profile
| Method | Arguments | Description |
|---|---|---|
| setSelectedShippingAddress | addr: ShippingAddress | Updates the shipping address within the checkout context. |
| setSelectedBillingAddress | addr: ShippingAddress | Updates the billing address within the checkout context. |
| setCustomerEmail | email: string | Updates the reference email associated with the current order. |
| setUseBillingAsShipping | flag: boolean | Toggles automatic equality between billing and shipping addresses. |
Methods: Checkout and Final Operations
| Method | Arguments | Description |
|---|---|---|
| handleCheckout | - | Triggers final validation, locks inventory, and redirects to the payment gateway. |
Mandatory Validation
Before invoking handleCheckout(), it is necessary to verify that shipping.compatible is true. Otherwise, the backend will reject the order creation as there are no valid shipping methods for the selected destination.