vendor/Shopify.js
Interact with the Shopify Admin API.
Returns
Make a request to a Shopify site.
This is just a wrapper to Mesa.shopify.request.
Returns
Shopify.get(path[, options, connectionInfo])
Make a GET request to a Shopify site.
Parameters
Additional configuration for Shopify calls
If you would like to connect to a separate Shopify website that Mesa is not installed on, create a Custom App and include a connectionInfo object.
Returns
handleImageList(path, options, connectionInfo)
Handles listing of images with pagination.
Parameters
- Shopify REST endpoint path.
- Connection info for external Shopify sites.
Returns
Array Array of images in REST format.
handleImage(originalPath, options, connectionInfo)
Handles retrieval of a single image by its ID for a specific product.
Parameters
- Original API endpoint path.
- Query options (not used in this implementation).
- Connection information for Shopify.
Returns
Object Processed image data in REST format.
handleProductCount(options, connectionInfo)
Handles the product count query.
Parameters
Returns
Handles paginated GraphQL queries for products or variants.
Parameters
- Function that generates a GraphQL query.
- Query options, including filters and limits.
- Function to transform the returned data into the desired REST format.
- Optional connection info for external Shopify sites.
Returns
Array Array of transformed paginated results.
handleProductList(path, options, connectionInfo)
Handles listing of products with pagination.
Parameters
- Shopify REST endpoint path.
- Connection info for external Shopify sites.
Returns
Array Array of products in REST format.
Shopify.handleProduct(originalPath, options, connectionInfo)
Retrieve a single product by ID using GraphQL and convert it to REST format.
Parameters
- Original API endpoint path.
- Options containing query parameters.
- Connection information for a separate Shopify store.
Returns
object Product data in REST format.
Shopify.handleProductPost(data[, connectionInfo])
Handles the creation of a product and its variants, if provided. Converts the REST payload into the appropriate GraphQL format.
Parameters
- The product data in REST API format.
- Connection information for Shopify.
Returns
Object - The product payload in REST API format.
handleVariantList(path, options, connectionInfo)
Handles listing of variants with pagination.
Parameters
- Shopify REST endpoint path.
- Connection info for external Shopify sites.
Returns
Array Array of variants in REST format.
Shopify.handleVariant(originalPath, options, connectionInfo)
Retrieve a specific variant by product ID and variant ID using GraphQL and convert it to REST format.
Parameters
- Original API endpoint path.
- Options containing query parameters.
- Connection information for a separate Shopify store.
Returns
object Variant data in REST format.
handleImagePost(data, connectionInfo)
Handles the creation of a product image. Converts the REST payload to GraphQL format and returns the response in REST format.
Parameters
- The REST image payload.
- Shopify connection info.
Returns
Object - The image payload in REST format.
send(query, variables, connectionInfo, endpoint)
Send a GraphQL query to Shopify.
Parameters
Returns
Shopify.post(path, data[, options, connectionInfo])
Make a POST request to a Shopify site.
By default Shopify calls will auto-wrap any outgoing JSON data, eg. Shopify.post('/admin/products.json', data) will result in { "product": { data } } use options.skipJsonWrap=true to override this behavior
Parameters
Additional configuration for Shopify calls
If you would like to connect to a separate Shopify website that Mesa is not installed on, create a Custom App and include a connectionInfo object.
Returns
handleVariantPut(productId, variantId, data, connectionInfo)
Handles updating a single variant for a specific product.
Parameters
- The variant data to update.
- Shopify connection details.
Returns
Object - The updated variant in REST format.
handleProductPut(productId, data, connectionInfo)
Handles the updating of a product and its related entities (variants, images, etc.).
Parameters
- The ID of the product to update.
- The product data to update.
- Shopify connection details.
Returns
Object - The updated product in REST format.
Shopify.put(path, data[, options, connectionInfo])
Make a PUT request to a Shopify site.
By default Shopify calls will auto-wrap any outgoing JSON data, eg. Shopify.put('/admin/products.json', data) will result in { "product": { data } } use options.skipJsonWrap=true to override this behavior
Parameters
Additional configuration for Shopify calls
If you would like to connect to a separate Shopify website that Mesa is not installed on, create a Custom App and include a connectionInfo object.
Returns
Shopify.patch(path, data[, options, connectionInfo])
Make a PATCH request to a Shopify site.
By default Shopify calls will auto-wrap any outgoing JSON data, eg. Shopify.patch('/admin/products.json', data) will result in { "product": { data } } use options.skipJsonWrap=true to override this behavior
Parameters
Additional configuration for Shopify calls
If you would like to connect to a separate Shopify website that Mesa is not installed on, create a Custom App and include a connectionInfo object.
Returns
Shopify.delete(path[, options, connectionInfo])
Make a DELETE request to a Shopify site.
By default Shopify calls will auto-wrap any outgoing JSON data, eg. Shopify.post('/admin/products.json', data) will result in { "product": { data } } use options.skipJsonWrap=true to override this behavior
Parameters
Additional configuration for Shopify calls
If you would like to connect to a separate Shopify website that Mesa is not installed on, create a Custom App and include a connectionInfo object.
Returns
getMyshopifyDomain(context)
Returns myshopify domain from the connection.
Parameters
Returns
string The myshopify domain. Ex: mystore.myshopify.com
getShopifyAdminUrl(context)
Returns myshopify domain from the connection.
Parameters
Returns
string The Shopify admin url, including https://. Ex: https://admin.shopify.com/store/mystore
getShopifyUuid(context)
Returns the subdomain part of the myshopify domain from the connection.
Parameters
Returns
string The subdomain part of the myshopify domain. Ex: mystore
deleteProduct(path, options, connectionInfo)
Delete a product by ID.
Parameters
- Shopify REST endpoint path.
- Connection info for external Shopify sites.
Returns
deleteVariant(path, options, connectionInfo)
Delete a variant by ID.
Parameters
- Shopify REST endpoint path.
- Connection info for external Shopify sites.
Returns
deleteImage(path, options, connectionInfo)
Delete a product image by ID.
Parameters
- Shopify REST endpoint path.
- Connection info for external Shopify sites.
Returns
getAllProducts([query={}, limit=250])
Make consecutive calls to Shopify in order to retrieve all products. https://help.shopify.com/en/api/reference/products/product
Parameters
Parameters to append to the Shopify querystring.
Result count for Shopify query.
Examples
Returns
appendToArray([data], The)
Update a value if it already exists, or append it to the array if it does not exist. The example routine below should be every time we are updating tags or note_attributes to ensure that multiple Automations will work nicely with each other and not overwrite values set in other Automations.
Parameters
An array of values that you would like to append a value to
value to append to the array. For tags, this would be a string. For note_attributes, this would be an object.
Examples
Returns
getVariantInventoryData(variantId)
Get inventory location information for a Shopify variant. https://help.shopify.com/en/api/reference/inventory/inventorylevel
Parameters
Examples
Returns
<a href="#object-inventorydata">InventoryData</a>
buildVariantInventoryUpdate(variantId, inventoryCount[, adjust=true, fulfillableAlter])
Build InventoryLevel update information for a Shopify variant. https://help.shopify.com/en/api/reference/inventory/inventorylevel
Parameters
Value to set as inventory.
Switch for available_adjustment vs available.
Callback function allows fulfillment location to be altered.
Examples
Returns
<a href="#object-inventoryupdatedata">InventoryUpdateData</a>
{Object} Options()
options parameter for Shopify calls
By default Shopify calls will auto-wrap any outgoing JSON data, eg. Shopify.post('/admin/products.json', data) will result in { "product": { data } } use skipJsonWrap=true to override this behavior
Properties
Returns
{Object} ConnectionInfo()
connectionInfo parameter for Shopify calls
Properties
Returns
{Object} FulfillableLocation()
Fulfillable location shape returned by fulfillableAlter https://help.shopify.com/en/api/reference/inventory/location
Parameters
The ID of the location that the inventory level belongs to.
Returns
{Function} fulfillableAlter(inventoryLevels)
Callback allows buildVariantInventoryUpdate fulfillment location to be altered. https://help.shopify.com/en/api/reference/inventory/inventorylevel
Parameters
Inventory levels for the variant at different locations.
inventoryLevels.inventory_item_id
Inventory item id for variant
inventoryLevels.location_id
inventoryLevels.available
inventoryLevels.updated_at
Returns
<a href="#object-fulfillablelocation">FulfillableLocation</a> fulfillableLocation
{Object} InventoryData()
Return from getVariantInventoryData.
Properties
Returns
{Object} InventoryUpdateData()
Return from buildVariantInventoryUpdate. Will either have available or available_adjustment depending on adjust param. https://help.shopify.com/en/api/reference/inventory/inventorylevel
Properties
Returns