Skip to main content

The wr.cart Object

wr.cart is available within the cart page and is useful for retrieving information about the cart and shipping, manipulating the state, or initiating the checkout process.

wr.cart.state

This object is designed to store all billing, delivery, and cart total data.

Below we will directly look at the states it exports and their relative utilities.

Example:

{
"customerEmail": "[email protected]",
"deliverySelections": {
"43add257-6334-4f25-b0bd-4db878dd9308": "shipping",
"01e1c35f-8cb2-4c35-bd8b-1fa42dbc6a8c": "shipping"
},
"selectedShippingAddress": {
"id": "7c3aaaf7-7fc5-4d24-9bca-f84640d91a9c",
"storeId": "a7734977-c5b1-49a4-911c-0b0bf745bd4f",
"customerId": "00e72027-3672-4c12-a78f-e9ff744a0892",
"fullName": "John Doe",
"company": "Webround",
"phone": "+IT 1234567890",
"addressLine1": "Street N.1",
"addressLine2": "n. 2",
"city": "Rome",
"postalCode": "00100",
"province": "Italia",
"countryCode": "IT",
"additionalInfo": "Green house",
"isDefaultShipping": true,
"isDefaultBilling": true,
"createdAt": "2025-12-20T14:00:09.069Z",
"updatedAt": "2025-12-20T14:00:37.558Z"
},
"selectedBillingAddress": {
"id": "7c3aaaf7-7fc5-4d24-9bca-f84640d91a9c",
"storeId": "a7734977-c5b1-49a4-911c-0b0bf745bd4f",
"customerId": "00e72027-3672-4c12-a78f-e9ff744a0892",
"fullName": "John Doe",
"company": "Webround",
"phone": "+IT 1234567890",
"addressLine1": "Street N.1",
"addressLine2": "n. 2",
"city": "Rome",
"postalCode": "00100",
"province": "Italia",
"countryCode": "IT",
"additionalInfo": "Green house",
"isDefaultShipping": true,
"isDefaultBilling": true,
"createdAt": "2025-12-20T14:00:09.069Z",
"updatedAt": "2025-12-20T14:00:37.558Z"
},
"shipping":{
"compatible": true,
"methods": [
{
"availableCountries": [
"IT",
"SM",
"CH"
],
"enabled": true,
"etaMax": 7,
"etaMin": 3,
"label": "Italian Standard Shipping",
"maxVolume": 5000000,
"maxWeight": 100000,
"methodId": "30ba1461-8f03-4586-a850-d69416aeef38",
"pricing": {
"eur": {
"base": 8,
"perKg": 0.5,
"toWeight": 100000,
"perVolume": 0,
"fromWeight": 10000,
"enableFreeShipping": true,
"freeShippingThreshold": 250
}
},
"provider": "Poste Italiane",
"costNet": 12.35,
"surchargeNet": 0,
"vatRate": 22,
"vatAmount": 2.717,
"totalGross": 15.067
},
{
"availableCountries": [
"IT"
],
"enabled": true,
"etaMax": 3,
"etaMin": 1,
"label": "Italian Shipping",
"maxVolume": 0,
"maxWeight": 0,
"methodId": "e16fe755-8fce-4c9d-a157-f7e67a6dae9b",
"pricing": {
"eur": {
"base": 10,
"perKg": 0,
"perVolume": 0
}
},
"provider": "Provider",
"costNet": 10,
"surchargeNet": 0,
"vatRate": 22,
"vatAmount": 2.2,
"totalGross": 12.2
}
],
"selected": {
"availableCountries": [
"IT"
],
"enabled": true,
"etaMax": 3,
"etaMin": 1,
"label": "Italian Shipping",
"maxVolume": 0,
"maxWeight": 0,
"methodId": "e16fe755-8fce-4c9d-a157-f7e67a6dae9b",
"pricing": {
"eur": {
"base": 10,
"perKg": 0,
"perVolume": 0
}
},
"provider": "Provider",
"costNet": 10,
"surchargeNet": 0,
"vatRate": 22,
"vatAmount": 2.2,
"totalGross": 12.2
},
"reason": null
},
"orderDeliveryMethod": "30ba1461-8f03-4586-a850-d69416aeef38",
"useBillingAsShipping": true,
"cartTotalGross": 142.74,
"cartTotalNet": 117
}

wr.cart.state.shipping

The shipping property is fundamental for checking shipping feasibility and the related costs. Here is an example:

{
"compatible": true,
"methods": [
{
"availableCountries": [
"IT",
"SM",
"CH"
],
"enabled": true,
"etaMax": 7,
"etaMin": 3,
"label": "Italian Standard Shipping",
"maxVolume": 5000000,
"maxWeight": 100000,
"methodId": "30ba1461-8f03-4586-a850-d69416aeef38",
"pricing": {
"eur": {
"base": 8,
"perKg": 0.5,
"toWeight": 100000,
"perVolume": 0,
"fromWeight": 10000,
"enableFreeShipping": true,
"freeShippingThreshold": 250
}
},
"provider": "Poste Italiane",
"costNet": 12.35,
"surchargeNet": 0,
"vatRate": 22,
"vatAmount": 2.717,
"totalGross": 15.067
},
{
"availableCountries": [
"IT"
],
"enabled": true,
"etaMax": 3,
"etaMin": 1,
"label": "Italian Shipping",
"maxVolume": 0,
"maxWeight": 0,
"methodId": "e16fe755-8fce-4c9d-a157-f7e67a6dae9b",
"pricing": {
"eur": {
"base": 10,
"perKg": 0,
"perVolume": 0
}
},
"provider": "Provider",
"costNet": 10,
"surchargeNet": 0,
"vatRate": 22,
"vatAmount": 2.2,
"totalGross": 12.2
}
],
"selected": {
"availableCountries": [
"IT"
],
"enabled": true,
"etaMax": 3,
"etaMin": 1,
"label": "Italian Shipping",
"maxVolume": 0,
"maxWeight": 0,
"methodId": "e16fe755-8fce-4c9d-a157-f7e67a6dae9b",
"pricing": {
"eur": {
"base": 10,
"perKg": 0,
"perVolume": 0
}
},
"provider": "Provider",
"costNet": 10,
"surchargeNet": 0,
"vatRate": 22,
"vatAmount": 2.2,
"totalGross": 12.2
},
"reason": null
}

See the Shipping type

Update

It is not necessary to manually recalculate the value of the shipping element. It updates automatically based on the current state of the cart.

Please refer to the wr.cart utilities page for a precise detail of all the properties and exposed states.

wr.cart Utilities