How can I access the Shopify object in JavaScript?

How can I access the Shopify object in JavaScript?

Joe63
Shopify Partner
9 0 0

Hi 

Is there any docs regarding the 'Shopify' object available in javascript? I keep seeing functions in theme docs for example Shopify.money_format() but no specific reference?

Thanks for any advice.

Joe

Replies 7 (7)

Ruairi_H
Shopify Staff (Retired)
61 0 3

Hi Joe,

Ruairi from Shopify here 🙂

You may be referring to the 'shop' liquid object, there is a 'shop.money_format' attribute which returns a string that is used by Shopify to format money without showing the currency.

You can read more about the shop object and its other attributes here: https://docs.shopify.com/themes/liquid-documentation/objects/shop

If this isn't what you are looking for, can you post a link of an example of the object you saw?

- Ruairi

Ruairi | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

Ruairi_H
Shopify Staff (Retired)
61 0 3

Hi Joe,

Ruairi from Shopify here again 🙂

After discussing this with a colleague I realised that you may be referring to a javascript object that is created by various Shopify scripts (such as option selectors, linked options, etc). The 'Shopify' js script is a global object that the scripts use to place all their functions and variables.

There are no documents on it specifically, but there is a tutorial here on using product javascript, which is related: https://docs.shopify.com/support/other/general-information/tutorial-on-using-product-javascript

- Ruairi

Ruairi | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

amruthcharank
Visitor
1 0 2

The link isn't working!

reed-lu
Shopify Partner
7 0 2

The link isn't working.

Looking for the official reply.

there is a similar question asked without any reply.

AllAwareTommy
Shopify Partner
6 0 1

@Ruairi_H Could you please provide a working link for any documentation related to the Shopify object?

aidantj
Shopify Partner
1 0 0

The "Tutorial on Using Product Javascript" is on the Internet Archive, but it's not a lot of info.

 

I don't have any additional docs to share, but I do have some reassurance that Shopify's not going to imminently decommission this object.

 

As folks here probably know, Dawn is Shopify's open-source, flagship theme.

 

Dawn not only extends the Shopify object, but Dawn also relies upon one of the Shopify object's undocumented properties. Granted, the property it relies doesn't power a customer-facing, experience-breaking feature. But the fact that Shopify's own premier theme is still relying on part of the object reassures me that they're not going to drop it for now.

Aidan

Patrick_S
Shopify Partner
2 0 2

You can try to learn about the global Shopify object by going to a Shopify store, opening inspect tool, and typing Shopify into the console.

Patrick_S_0-1699399418772.png

 

You can also search for the "Shopify." object in VSCode and read the JavaScript files.

Patrick Szydlowski