Skip to main content

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.

PropertyTypeDescription
deliverySelectionsRecord<string, DeliveryMethod>Map associating each SKU ID in the cart with the chosen delivery method (shipping, pickup, digital, none).
customerEmailstringThe user's email for contact or guest checkout.
selectedShippingAddressShippingAddressThe address entered by the customer for shipping.
selectedBillingAddressShippingAddressThe address entered by the customer for billing.
useBillingAsShippingbooleanFlag to use the billing address for shipping.
orderDeliveryMethodstring (UUID)The ID of the shipping method chosen for the order. (Found in wr.cart.state.shipping under the methodId property.)
cartTotalNetnumberNet total of the cart (taxable).
cartTotalGrossnumberFinal gross total (inclusive of VAT and shipping).
shippingShippingCalculated object containing compatible methods and dynamic costs.
validatedCouponsCoupon[]List of applied and validated coupons.

Methods: Delivery Management

MethodArgumentsDescription
setDeliveryMethoditemId: string, method: DeliveryMethodSets the delivery mode for a single item in the cart.
setOrderDeliveryMethodmethodId: stringSets the global shipping method for the entire order.
clearElementitemId: stringRemoves the delivery selections made for a specific item.

Methods: Addresses and Profile

MethodArgumentsDescription
setSelectedShippingAddressaddr: ShippingAddressUpdates the shipping address within the checkout context.
setSelectedBillingAddressaddr: ShippingAddressUpdates the billing address within the checkout context.
setCustomerEmailemail: stringUpdates the reference email associated with the current order.
setUseBillingAsShippingflag: booleanToggles automatic equality between billing and shipping addresses.

Methods: Checkout and Final Operations

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