useCart
Returns a full cart
object
Any .jsx file
import { useCart } from '@backpackjs/storefront';
const CartNote = () => {
const cart = useCart();
return <h3>{cart.note}</h3>
}
Example cart object
{
"__typename": "Checkout",
"id": "Z2lkOi8vc2hvcGlmeS9DaGVja291dC80NDE1NGE0ZDZjNGIyMTY5YTA0MzMzMzY5OTIwMjE2MT9rZXk9MWEzMjJlZDhjZjFhMzZhYTg4YTVmMjk5ZTM0N2I0YmQ=",
"ready": true,
"requiresShipping": true,
"note": "This is my note",
"paymentDue": "772.20",
"paymentDueV2": {
"amount": "772.2",
"currencyCode": "USD",
"type": {
"name": "MoneyV2",
"kind": "OBJECT",
"fieldBaseTypes": {
"amount": "Decimal",
"currencyCode": "CurrencyCode"
},
"implementsNode": false
}
},
"webUrl": "https://backpack-storefront.myshopify.com/56658821304/checkouts/44154a4d6c4b2169a043333699202161?key=1a322ed8cf1a36aa88a5f299e347b4bd",
"orderStatusUrl": null,
"taxExempt": false,
"taxesIncluded": false,
"currencyCode": "USD",
"totalTax": "0.00",
"totalTaxV2": {
"amount": "0.0",
"currencyCode": "USD",
"type": {
"name": "MoneyV2",
"kind": "OBJECT",
"fieldBaseTypes": {
"amount": "Decimal",
"currencyCode": "CurrencyCode"
},
"implementsNode": false
}
},
"lineItemsSubtotalPrice": {
"amount": "858.0",
"currencyCode": "USD",
"type": {
"name": "MoneyV2",
"kind": "OBJECT",
"fieldBaseTypes": {
"amount": "Decimal",
"currencyCode": "CurrencyCode"
},
"implementsNode": false
}
},
"subtotalPrice": "772.20",
"subtotalPriceV2": {
"amount": "772.2",
"currencyCode": "USD",
"type": {
"name": "MoneyV2",
"kind": "OBJECT",
"fieldBaseTypes": {
"amount": "Decimal",
"currencyCode": "CurrencyCode"
},
"implementsNode": false
}
},
"totalPrice": "772.20",
"totalPriceV2": {
"amount": "772.2",
"currencyCode": "USD",
"type": {
"name": "MoneyV2",
"kind": "OBJECT",
"fieldBaseTypes": {
"amount": "Decimal",
"currencyCode": "CurrencyCode"
},
"implementsNode": false
}
},
"completedAt": null,
"createdAt": "2021-08-28T18:05:49Z",
"updatedAt": "2021-09-04T06:21:30Z",
"email": "juan.prieto@packdigital.com",
"discountApplications": [
...discountApplications
],
"appliedGiftCards": [],
"shippingAddress": null,
"shippingLine": null,
"customAttributes": [
...customAttributes
],
"order": null,
"lineItems": [
...lineItems
],
"type": {
...type
}
}
Last updated