before-open-checkout
This function is triggered before opening the checkout page.
Description
It can be used to modify the checkout page before it is opened. For example, you can use this function to redirect the user to a different page rather than the default checkout page.
Usage
appmakerFunctions.registerAppmakerFn({
trigger: 'before-open-checkout',
namespace: 'namespace',
function: myFunctionHook,
});
Parameters
You get the following parameters in the function hook:
- currentCart - The cart object.
- accessToken - The access token of the user.
Return
The function should return the modified parameters.
Example
Below is the sample code to intercept and return a custom url for appmaker checkout:
import appmakerFunctions from '@appmaker-xyz/core';
appmakerFunctions.registerAppmakerFn({
trigger: 'before-open-checkout',
namespace: 'namespace',
function: myFunctionHook,
});
function myFunctionHook({currentCart,accessToken}) {
return {
webUrl: 'https://appmaker.xyz',
}
}
The above code will redirect the user to the url https://appmaker.xyz
when the checkout page is opened.
To manage the cart on App we use GraphQL Storefront checkout API. Sample cart JSON is available here.