loyaltylion.webview.methodName
, where methodName
is one of the documented
API methods below.
Interacting with the JS API is typically not required for a basic WebView setup,
but is often used to support advanced features
Unless otherwise specified, you must wait for the LoyaltyLion SDK to report that
it has finished loading before using WebView APIs. You can do this by listening
to the sdkReady event.
loyaltylion.webview.setShopifyCartState
This can be used to inform the LoyaltyLion SDK about the current Shopify cart
state, which is needed for some functionality. For example, free product rewards
often require a cart to contain a paid item before they can be redeemed, so the
SDK needs to know about the cart first.
setShopifyCartState
expects a single argument, which should be a JSON object
representing the cart state. All fields can be retrieved from the Storefront API
Cart object.
cost.totalAmount.amount
on the Storefront API Cart
object.