@eastsideco/escshopify
Version:
WIP JS library for Shopify, containing a variety of useful functionality.
59 lines (36 loc) • 1.51 kB
Markdown
The Shop entity represents global shop settings and details (i.e. contact email address, policies, URL, etc.)
This entity is read-only, and it properties match that of the Shopify `shop` liquid object. There are some extra methods and properties added for convinience.
## Examples
**ES6**:
```js
import {entities, utils} from '@eastsideco/escshopify';
const shop = new entities.Shop;
// Accessing shop properties:
var primaryDomain = shop.domain;
var myshopifyDomain = shop.permanent_domain;
var storeName = shop.name;
var defaultCurrency = shop.currency;
var averageCollectionSize = shop.products_count / shop.collections_count;
// Generating absolute shop URLs:
var absoluteUrl = shop.makeAbsoluteUrl('/collections/all'); // https://shop.com/collections/all
var permanentUrl = shop.makePermanentUrl('/collections/all'); // https://shop.myshopify.com/collections/all
```
Before using the shop module, you should initialize it with the global shop state, for eaxmple from a binding created in Liquid.
_This is done for you automatically if you use SALVO._
**ES6**:
```js
import {entities, utils} from '@eastsideco/escshopify';
const shop = new entities.Shop;
shopData = { name: '...', domain: '...', ... };
shop.initialize(shopData);
```
Listen to the following events to track the lifecycle of this entity.
The shop entity was initialized.
```txt
Object shop - The current shop entity.
```