JavaScript API
The storefront object, the theme selectors you can override, and the events the app fires.
This page is for developers working on a theme. Nothing here is needed to use the app normally — it exists for the cases where a theme does something unusual enough that the app’s own settings cannot reach it.
Everything below runs on the storefront and needs the app embed enabled. Without it, none of these objects or events exist.
window.GPOConfigs
The app’s storefront object. It is created by the app embed before the app’s own script runs, which is what makes the overrides below possible.
| Property | What it holds |
|---|---|
theme | The selectors the app uses to find things in your theme. See Theme selectors |
page.type | The Shopify page type — product, cart, index, collection, and so on |
product | The current product, as Shopify's product JSON, plus product.collections with the collection ids it belongs to. false off a product page |
cart | The current cart, as Shopify's cart JSON |
customer | id, name, email, and tags for a signed-in customer, or false. The tags are what customer rules match on |
curCountryCode | The visitor's country, as a two-letter code. What country rules match on |
money_format | The money format the app formats prices with, which follows your add-on price settings |
initialize() | Runs the app again. See Re-running the app |
The rest of this section
Re-running the app
GPOConfigs.initialize() runs the app again from the start. Use it when something replaces the product form after the page has loaded — a page builder swapping sections, or a theme that re-renders the product on variant change.
window.GPOConfigs && window.GPOConfigs.initialize();Call it after the new markup is in the DOM, not before. Calling it when nothing has changed re-renders the options unnecessarily, so trigger it from your theme’s own “section replaced” signal rather than on a timer.
Notes
- All of this needs the app embed enabled on the published theme. See Enable the app embed.
GPOConfigsexists on every page the app embed runs on, butproductisfalseaway from a product page.- Overriding selectors does not change what the options collect, only where the app finds things in your theme.
- If a theme needs the same override on every store running it, send it to us instead of repeating it per store. See Contact support.
Was this helpful?
Thanks for your feedback! Tell us what was missing
Report an issue