Skip to content
Log in

scAction

On this page

scAction is a global JavaScript function available in the POS. It lets custom code in POS views (Liquid templates rendered in the POS) and inline HTML trigger any POS action programmatically.

Signature

javascript scAction(action, params, options)

Parameter Type Required Description
action String Yes The action identifier (e.g. 'cart:add_product')
params Object No Key-value pairs of action parameters
options Object No Optional callbacks: { onSuccess, onError }

Options

Option Type Description
onSuccess Function Called after the action and any chained actions complete successfully.
onError Function Called with an Error if any link in the chain rejects — including a missing chained action. Also called synchronously when no action is provided.

Usage

Adding a product to the cart

javascript scAction('cart:add_product', { product_code: 'SKU123', quantity: 2 })

Starting checkout

javascript scAction('checkout:start')

Opening a modal

javascript scAction('modal:open:url', { url: '/custom/page' })

In a Liquid/HTML POS view

```html

```

Reacting to success or failure

Pass onSuccess and/or onError to handle the outcome of the action:

javascript scAction( 'cart:add_product', { product_code: 'SKU123', quantity: 1 }, { onSuccess: () => console.log('Added to cart'), onError: (error) => console.error('Failed to add:', error), } )

If onError is not provided, chain errors are still logged to the browser console via console.error.

Notes

  • Callbacks use callback-style (not Promise) to avoid issues with React’s Suspense boundary during action dispatch.
  • Action identifiers must use snake_case from v21. Dash-case identifiers still work but are deprecated.
  • [[pos-actions-reference POS actions reference]] — list of available action identifiers
  • [[pos-checkout-start-action checkout:start]] — start checkout programmatically
  • [[pos-sync-full-action sync:full]] — force a full POS data sync

Was this article helpful?

Was this article helpful?