App Actions

Built-in outputs for driving conversions

Introduction

Actions can be referenced by your Javascript to invoke an action in the mobile app. This is where you will pair any business logic in your block with a direct outcome in your usersโ€™ experience.

Using an App Action

Actions will work out of the box as long as you are building inside of the Custom Blocks editor (In the Javascript tab). No further setup is required beyond using the proper syntax, and calling the function with the required parameters.

Testing Actions

App Actions do not return success/error states to the block upon being called. However, you can manually test actions via the block preview in the Custom Blocks text editor. Actions will be printed to the browser console when successfully invoked.

Available App Actions

addToCart

Use the addToCart to support interactions that add 1 or more products to the cart. This action accepts an array of lineItems, and additionally accepts custom line item attributes. Attributes are helpful for passing custom data back to Shopify, and any other downstream systems as a result of an order.

Tapcart.actions.addToCart({
    lineItems: [
        {
            variantId: 'String',
            quantity: Number,
            attributes: [ // optional
                {
                    key: 'String',
                    value: 'String',
                },
            ],
        },
    ],
})

๐Ÿ›’

Navigating the user to checkout

Upon invoking the addToCart function, the app will reference this setting to determine if the user should be automatically navigated to the cart, or left where they are.

openProduct

Use the openProduct to support interactions that take a user to a product detail page. This action accepts a productId, and an optional variantId if a specific variant needs to be pre-selecting upon opening the page. Setting isRelatedProduct to true will passively transition to new products from one PDP to another, setting it to false will reload a new page when transferring to a new PDP (Available only on PDPs).

Tapcart.actions.openProduct({
    productId: 'String',
    variantId: 'String', // optional
    isRelatedProduct: Boolean // optional, works only on PDPs
}

openCollection

Use the openCollection to support interactions that take a user to a product list page. This action accepts a collectionId.

Tapcart.actions.openCollection({
    collectionId: 'String',
})

showToast

Use the showToast to display success or error messages to your end users. This will display natively & will be presented at the top of the page. This action accepts a a message, and a type to denote if it's a success or error message.

Tapcart.actions.showToast({
    message: 'String',
    type: 'String', // "success" || "error"
})
Example of a 'Success' toast

Example of a 'Success' toast

Example of an 'Error' toast

Example of an 'Error' toast