CartItem - browsing, updating and removing a shopping cart item

This resource allows you to retrieve an item from a shopping cart (GET), update the quantity of an item in the cart (POST), or remove an item from the cart (DELETE)

Retrieving the cart item

Usually you would retrieve cart items with a GET request to the Cart resource. However it is possible to query just a single node by issuing a GET request to /API/V3/CartItem/$id - where $id is the id of the CartItem.

Keep in mind you will need to pass your session token (as retrieved from the ResultSet node of your last call) as e.g. ?_session_token=5ybb8je8aM8QNRy. See the API session documentation for more information.

Expected result

The expected result will look something like this:

<ResultSet session="5ybb8je8aM8QNRy" totalItems="2" totalQuantity="3" xmlns="http://www.zeald.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.zeald.com https://mydomain.nz/API/V3/CartItem.xsd">
    <CartItem href="https://mydomain.nz/API/V3/CartItem/NlE438vaQEOOSq4UD5tkjA" id="Ecommerce::CartItem::NlE438vaQEOOSq4UD5tkjA">
        <sku>10412</sku>
        <title>Green Tshirt</title>
        <description></description>
        <thumb>green-tshirt.png</thumb>
        <image>green-tshirt.png</image>

        <!-- prices generally have a numeric and a `*_formatted` version which includes currency symbol -->
        <price>22.00</price>
        <price_formatted>$22.00</price_formatted>
        <quantity>1</quantity>
        <subtotal>22.00</subtotal>
        <subtotal_formatted>$22.00</subtotal_formatted>
    </CartItem>
</ResultSet>

If the product has options it will have a few additional nodes:

<ResultSet session="5ybb8je8aM8QNRy" totalItems="2" totalQuantity="3" xmlns="http://www.zeald.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.zeald.com https://mydomain.nz/API/V3/CartItem.xsd">
    <CartItem href="https://mydomain.nz/API/V3/CartItem/C-7f5YZ9TFWfhOMmD4oQ5Q" id="Ecommerce::CartItem::C-7f5YZ9TFWfhOMmD4oQ5Q">
        <sku>10442</sku>
        <title>Long Pants</title>

        <!--
            Additional description information where required.
                - If this product has options are selected, a string representing the selected options.
                - If this product has advanced options, the "subproduct" description
        -->
        <description>Size: Small, Colour: Blue</description>

        <thumb>long-pants.jpg</thumb>
        <image>long-pants.jpg</image>

        <!--
            Options for this product. Each option wrapped in <option> and contains:
                - group - the identifier for this option
                - group_label - the output ready name of this option
                - value - the selected option value
                - label - the output ready label of the selected value
        -->
        <option>
            <group>size</group>
            <group_label>Size</group>
            <value>sm</sm>
            <label>Small</label>
        </option>
        <option>
            <group>colour</group>
            <group_label>Colour</group_label>
            <value>blue</value>
            <label>Blue</label>
        </option>

        <price>15.00</price>
        <price_formatted>$15.00</price_formatted>
        <quantity>2</quantity>
        <subtotal>30.00</subtotal>
        <subtotal_formatted>$30.00</subtotal_formatted>
    </CartItem>
</ResultSet>

If the product has advanced options, or subproducts, look out for a <code> node which will contain the variant code for identifying the subproduct line.

Updating an item in a cart

If you POST (or PUT) xml to this resource, the resulting CartItem will be updated. Currently only updating quantity is supported.

To do this you usually will have retrieved CartItem contents from the Cart resource - as you will need to know the id of the CartItem you are updating to post to the correct resource path.

Don't forget the session token. After updating, the full cart contents will be returned along with subtotals etc.

Example

POST to https://mydomain.nz/API/V3/CartItem/NlE438vaQEOOSq4UD5tkjA

<ResultSet xmlns="http://www.zeald.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.zeald.com https://mydomain.nz/API/V3/Cart.xsd">
    <CartItem>
        <quantity>3</quantity>
    </CartItem>
</ResultSet>

Alternatively simply POST to https://mydomain.nz/API/V3/CartItem/NlE438vaQEOOSq4UD5tkjA?quantity=3

Deleting an item from the cart

DELETE to https://mydomain.nz/API/V3/CartItem/NlE438vaQEOOSq4UD5tkjA will remove the item matching that id from whatever cart it is a part of.

Don't forget the session token. After updating, the full cart contents will be returned along with subtotals etc.