This page covers reading back a cart that holds rental lines. It applies to Rental Booking 1.2.213 and later, and to the headless flow in Booking from a Headless Storefront.
Before 1.2.213, reading cart.items for a cart that held a rental line failed with the error Product "sirent" type is not supported, so a headless storefront could not show the cart that addRentalProductsToCart had just returned. Rental lines now come back as a RentalCartItem.
RentalCartItem #
A rental line is a CartItemInterface like any other, so the usual fields (uid, product, quantity, prices) work. It adds two things:
| Field | Type | Meaning |
|---|---|---|
customizable_options | [SelectedCustomizableOption]! | The custom options the shopper selected. The rental Start Date and End Date options are included. |
rental_dates | RentalCartItemDates | The dates the line is rented and charged for, as the cart reads them. Null for a line without dates, such as a buy-out. |
RentalCartItemDates has two fields, start_date and end_date, both as Y-m-d H:i:s in the store’s time. A rental booked by whole days ends at 23:59:00 of its last day.
Query #
query CartWithRentals {
cart(cart_id: "Zk3x9QJ0example") {
items {
uid
quantity
product { sku name }
prices { row_total { value currency } }
... on RentalCartItem {
rental_dates { start_date end_date }
customizable_options { label values { label } }
}
}
prices { grand_total { value currency } }
}
}
Prices match the cart #
In 1.2.213 the product page, the admin order popup and the rentalProductPrice query all quote the price the cart charges. For a rental picked by date only, rentalProductPrice reports the whole-day end and the duration the cart uses, so a headless storefront shows the same total the cart will. What the cart charges is unchanged.
Not in GraphQL yet #
The rental search (the search widget and results page) is built for the storefront only in 1.2.213 and has no GraphQL query yet. A headless storefront can use rentalProductAvailability, rentalProductCalendar and rentalProductPrice (Availability & Calendar Queries and Pricing Queries) to show what is free for chosen dates.
Booking deposits #
If the store takes booking deposits, the same cart also has rental_payment, which tells the storefront whether a deposit is offered and what is due today. See Booking Deposits & Balances.
