Skip to content

Instantly share code, notes, and snippets.

@agaerig
Last active July 31, 2019 17:58
Show Gist options
  • Select an option

  • Save agaerig/33827f11ff2cb31f0e8678d11ed855ff to your computer and use it in GitHub Desktop.

Select an option

Save agaerig/33827f11ff2cb31f0e8678d11ed855ff to your computer and use it in GitHub Desktop.
const sku = 'swg_stepped_pricing_test';
const getWindowSwg = (context = window) => {
// eslint-disable-next-line compat/compat
return new Promise((resolve, _reject) => {
// SWG (global): represents an array of handlers that are called back
// with a reference to the Subscriptions API once the library is loaded.
// eslint-disable-next-line no-param-reassign
(context.SWG = context.SWG || []).push((swg) => resolve(swg));
});
};
getWindowSwg().then((swgClient) => {
swgClient.subscribe(sku);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment