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 6 (6)

Ruairi_H
Shopify Staff
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
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?

Patrick_S
Shopify Partner
2 0 1

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