Skip to content

Instantly share code, notes, and snippets.

View lizkenyon's full-sized avatar

Liz Kenyon lizkenyon

View GitHub Profile
@lizkenyon
lizkenyon / app.js
Created May 15, 2024 21:31
Bulk Mutation
const express = require("express");
require("@shopify/shopify-api/adapters/node");
const { shopifyApi, ApiVersion, Session } = require("@shopify/shopify-api");
const { restResources } = require("@shopify/shopify-api/rest/admin/2023-04");
const app = express();
const shopify = shopifyApi({
apiSecretKey: "secret", // Note: this is the API Secret Key, NOT the API access token
apiVersion: ApiVersion.April24,
isCustomStoreApp: true, // this MUST be set to true (default is false)
@lizkenyon
lizkenyon / metaobjectReferencesProduct.liquid
Last active January 10, 2025 01:05
How to access product information that is referenced by a metaobject in liquid
{%
################################
# How to access product information that is referenced by a metaobject
#
#
# metaobject_references_a_product -> The type of of the metaobject definition. Settings > Custom Data > Your metafield definition > Type
# metaobject-references-a-product-ng8tvn4m -> The handle of the specific metaobject you want to access. Content > Metaobjects > Handle
# product -> The name of the product reference field, defined in your metafield definition. Settings > Custom Data > Your metafield definition
#
# Gotcha: Make sure the product that you are referencing has been published to the online store!
@lizkenyon
lizkenyon / returnedProduct.curl
Created July 4, 2022 22:10
ShopifyQL API | Show which products are most often returned
curl --location --request POST 'https://shop.myshopify.com/admin/api/unstable/graphql.json' \
--header 'X-Shopify-Access-Token: shpat_token123456' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"{\n # \"FROM sales SHOW total_sales BY month SINCE -1y UNTIL today\" passes a ShopifyQL query to the GraphQL query.\n shopifyqlQuery(query: \"FROM sales SHOW returned_item_quantity BY product_id SINCE -150d ORDER BY returned_item_quantity DESC\") {\n __typename\n ... on TableResponse {\n tableData {\n rowData\n columns {\n # Elements in the columns section describe which column properties you want to return.\n name\n dataType\n displayName\n }\n }\n }\n # parseErrors specifies that you want errors returned, if there were any, and which error properties you want to return.\n parseErrors {\n code\n message\n range {\n start {\n line\n character\n }\n end {\n
@lizkenyon
lizkenyon / graphQLGetProduct.php
Last active September 30, 2021 18:30
PHP Shopify GrapQL Product
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
//Shopify API Token
const SHOPIFY_ACCESS_TOKEN = '<123456789A>';
//Shopify store API token was generated for
const URL = 'https://yourstore.myshopify.com';
@lizkenyon
lizkenyon / getRestProduct.php
Last active September 30, 2021 18:33
PHP Shopify Rest
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
//Shopify API Token
const SHOPIFY_ACCESS_TOKEN = '<123456789A>';
//Shopify store API token was generated for
const URL = 'https://yourstore.myshopify.com';
@lizkenyon
lizkenyon / graphQLUpdate.php
Created June 14, 2021 16:29
PHP Shopify GraphQL Update
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
//Shopify API Token
const SHOPIFY_ACCESS_TOKEN = '<123456789A>';
//Shopify store API token was generated for
const URL = 'https://yourstore.myshopify.com';
@lizkenyon
lizkenyon / graphQLUpdate.js
Created June 14, 2021 16:27
JS Shopify GraphQL Update
const request = require('request');
//Shopify API Token
const shopifyToken = '<12345677890>';
//The shopify store associated with the API token
const url = 'https:/yourstore.myshopify.com';
//The Shopify API and version
const apiPrefix = '/admin/api/2020-10';
@lizkenyon
lizkenyon / putRESTProduct.php
Created June 14, 2021 16:21
PHP Shopify REST Update
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
//Shopify API Token
const SHOPIFY_ACCESS_TOKEN = '<123456789A>';
//Shopify store API token was generated for
const URL = 'https://yourstore.myshopify.com';
@lizkenyon
lizkenyon / getGraphQLProduct.go
Created June 14, 2021 16:12
Go Shopify GraphQL API
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
)
@lizkenyon
lizkenyon / getGraphQLProduct.js
Last active September 30, 2021 18:32
JS Shopify GraphQL API GET
const request = require('request');
//Shopify API Token
const shopifyToken = '<12345677890>';
//The shopify store associated with the API token
const url = 'https:/yourstore.myshopify.com';
//The Shopify API and version
const apiPrefix = '/admin/api/2020-10';