Skip to content

Instantly share code, notes, and snippets.

View jaredkc's full-sized avatar

Jared Cornwall jaredkc

  • Salt Lake City, UT
View GitHub Profile
@jaredkc
jaredkc / productsQueryById.graphql
Created September 29, 2024 23:07
Shopify GraphQL query for 2 specific products
query {
products(first: 10, query: "(id:1234567890) OR (id:0987654321)") {
edges {
node {
title
id
}
}
}
}
@jaredkc
jaredkc / productByHandleSellingPlans.graphql
Created September 29, 2024 18:57
Shopify GraphQL query productByHandle with sellingPlans
query {
productByHandle(handle: "protein-juice-cleanse") {
id
title
requiresSellingPlan
sellingPlanGroups(first:1) {
edges {
node {
sellingPlans(first: 6) {
edges {
@jaredkc
jaredkc / collectionByHandle.graphql
Created September 28, 2024 14:53
Shopify GraphQL collection query with product metafield
query productCollection($handle: String!, $firstProducts: Int!, $metafield: String!) {
collectionByHandle(handle: $handle) {
id
title
productsCount {
count
}
products(first: $firstProducts) {
edges {
node {
@jaredkc
jaredkc / placeholder-svgs.liquid
Created June 18, 2024 22:52
Shopify Placeholder SVGs. Outputs every Shopify placeholder_svg_tag available.
{% comment %}
Shopify Placeholder SVGs
Outputs every Shopify placeholder_svg_tag available. A simple reference to use during theme development.
https://shopify.dev/docs/api/liquid/filters/placeholder_svg_tag
{% endcomment %}
{%- liquid
assign outline_illustrations = 'product-1,product-2,product-3,product-4,product-5,product-6,collection-1,collection-2,collection-3,collection-4,collection-5,collection-6,lifestyle-1,lifestyle-2,image'
assign color_illustrations = 'product-apparel-1,product-apparel-2,product-apparel-3,product-apparel-4,collection-apparel-1,collection-apparel-2,collection-apparel-3,collection-apparel-4,hero-apparel-1,hero-apparel-2,hero-apparel-3,blog-apparel-1,blog-apparel-2,blog-apparel-3,detailed-apparel-1'
@jaredkc
jaredkc / reviewsio-metfield-query.graphql
Last active September 28, 2024 13:17
Reviews.io Shopify Product Metafields
"""
Metafields:
- reviewscouk.single_line_text_field
- reviewscouk.number_integer
- reviewscouk.static_product_widget
"""
{
productByHandle(handle: "your-product-handle") {
title
@jaredkc
jaredkc / app.products._index.jsx
Created January 19, 2024 22:17
Shopify Remix app page to search products via GraphQL and display with Polaris components
import { json } from "@remix-run/node";
import {
Page,
Layout,
Text,
BlockStack,
ResourceList,
ResourceItem,
Thumbnail,
Badge,
@jaredkc
jaredkc / app.products.$handle.jsx
Last active January 19, 2024 22:15
Shopify Remix App page to load product by handle with metafields from with GraphQL, display with Polaris components.
import { json } from "@remix-run/node";
import { Page, Layout, BlockStack } from "@shopify/polaris";
import { authenticate } from "../shopify.server";
import { useLoaderData } from "@remix-run/react";
export const loader = async ({ request, params }) => {
const handle = params.handle;
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
@jaredkc
jaredkc / checkout.liquid
Created November 1, 2023 20:32
The default Shopify checkout template. Used for reference to determine the level of customizations made.
<!DOCTYPE html>
<html lang="{{ locale }}" dir="{{ direction }}" class="{{ checkout_html_classes }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, height=device-height, minimum-scale=1.0, user-scalable=0">
<meta name="referrer" content="origin">
<title>{{ page_title }}</title>
@jaredkc
jaredkc / form-utilities.ts
Created June 6, 2023 13:37
Form Utilities
export function isValidEmail(email: string): boolean {
const re = /\S+@\S+\.\S+/;
const emailTest = re.test(email);
return emailTest;
}
export function isSecurePassword(password: string): boolean {
// TODO: remove this once we are past testing data
if (password.includes('testing')) return true;
@jaredkc
jaredkc / page.styles.liquid
Created October 8, 2019 16:37
Shopify template to visualize your site’s layout and styles with dummy content that is common across themes. This is a copy of the template that used to be available form Shopify's start theme template.
{% comment %}
Custom template for testing styles applied to RTE content.
Remove before deploying to production/publishing your theme.
{% endcomment %}
<style>
/* Styleguide styles */
.docs-title {
opacity: 0.5;
font-style: italic;