Update cart

Action ID
actions.intent.UPDATE_CART
Description
Add an item to a purchasing queue, such as a shopping cart. Filter the item to add by the name of the product using the cart.itemListElement.orderedItem.name parameter.

Locale support

Functionality Locales
Preview creation using App Actions test tool en-US, pt-BR
User invocation from Google Assistant en-US, pt-BR

Example queries

The following fields represent essential information that users often provide in queries that trigger this built-in intent:

cart.itemListElement.orderedItem.name

Other supported fields

The following fields represent information that users often provide to disambiguate their needs or otherwise improve their results:

cart.@type
cart.itemListElement.@type
cart.itemListElement.orderedItem.@type

Supported text values by field




Inventory availability by field


Sample XML files

For information about the actions.xml schema, see Create actions.xml. For information about the shortcuts.xml schema, see Create shorcuts.xml.

Handle BII parameters

shortcuts.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- This is a sample shortcuts.xml -->
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
  <capability android:name="actions.intent.UPDATE_CART">
    <intent
      android:action="android.intent.action.VIEW"
      android:targetPackage="YOUR_UNIQUE_APPLICATION_ID"
      android:targetClass="YOUR_TARGET_CLASS">
      <!-- Eg. name = "example name" -->
      <parameter
        android:name="cart.itemListElement.orderedItem.name"
        android:key="name"/>
    </intent>
  </capability>
</shortcuts>
      

actions.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- This is a sample actions.xml -->
<actions>
  <action intentName="actions.intent.UPDATE_CART">
    <fulfillment urlTemplate="myapp://custom-deeplink{?name}">
      <!-- e.g. name = "example name" -->
      <!-- (Optional) Require a field eg.name for fulfillment with required="true" -->
      <parameter-mapping urlParameter="name" intentParameter="cart.itemListElement.orderedItem.name" required="true" />
    </fulfillment>

    <!-- Provide a fallback fulfillment with no required parameters. For example, to your app search or router deeplink -->
    <fulfillment urlTemplate="myapp://deeplink" />
  </action>
</actions>

Use web inventory

cart.itemListElement.orderedItem.name is a field that supports web inventory. In the following example, Google Assistant performs a web search for the user query and determines the fulfillment URL. Assistant filters for search results that match the provided urlFilter value of https://www.mywebsite.com/link1/.*.

shortcuts.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- This is a sample shortcuts.xml -->
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
  <capability android:name="actions.intent.UPDATE_CART">
    <intent
      android:targetPackage="YOUR_UNIQUE_APPLICATION_ID"
      android:targetClass="YOUR_TARGET_CLASS">
      <parameter
        android:name="cart.itemListElement.orderedItem.name"
        android:key="name"/>
    </intent>
  </capability>
</shortcuts>
      

actions.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- This is a sample actions.xml -->
<actions>
  <action intentName="actions.intent.UPDATE_CART">
    <!-- Use URL from entity match for deep link fulfillment -->
    <!-- Example: url = 'https://www.mywebsite.com/link1/item1' -->
    <fulfillment urlTemplate="{@url}" />

    <!-- Provide a fallback fulfillment with no required parameters. For example, to your app search or router deeplink -->
    <fulfillment urlTemplate="myapp://deeplink" />

    <!-- Define parameters with web inventories using urlFilter -->
    <parameter name="cart.itemListElement.orderedItem.name">
      <entity-set-reference urlFilter="https://www.mywebsite.com/link1/.*" />"/>
    </parameter>
  </action>
</actions>

JSON-LD sample

The following JSON-LD sample provides some example values that you can use in the App Actions test tool:

{
  "@context": "http://schema.googleapis.com",
  "@type": "Cart",
  "itemListElement": {
    "@type": "OrderItem",
    "orderedItem": {
      "@type": "Product",
      "name": "example name"
    }
  }
}