L'oggetto wr.cart
wr.cart è disponibile all'interno della pagina cart ed è utile per recuperare informazioni sul carrello e sulla spedizione, manipolare lo stato o avviare il checkout.
wr.cart.state
L'oggetto è pensato per conservare tutti i dati di fatturazione, consegna e totale del carrello.
Di seguito vedremo direttamente gli stati che esporta e le relative utilities.
Esempio:
{
"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": "Spedizione Standard Italia",
"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": "Spedizione Italiana economica",
"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": "Spedizione Italiana economica",
"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
La proprietà shipping è fondamentale per consultare lo stato di fattibilità della spedizione e i relativi costi. Ecco un esempio:
{
"compatible": true,
"methods": [
{
"availableCountries": [
"IT",
"SM",
"CH"
],
"enabled": true,
"etaMax": 7,
"etaMin": 3,
"label": "Spedizione Standard Italia",
"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": "Spedizione Italiana economica",
"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": "Spedizione Italiana economica",
"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
}
Aggiornamento
Non è necessario ricalcolare manualmente il valore dell'elemento shipping. Si aggiorna automaticamente in base allo stato attuale del carrello.
Ti rimandiamo alla pagina delle utilities di wr.cart, dove avrai un dettaglio preciso su tutte le proprietà e gli stati esposti.