Skip to content

Instantly share code, notes, and snippets.

View jaredkc's full-sized avatar

Jared Cornwall jaredkc

  • Raw Generation
  • Salt Lake City, UT
View GitHub Profile
@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 / .graphql
Created April 29, 2024 14:16
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;
@jaredkc
jaredkc / functions.php
Last active August 29, 2015 14:26
Styles for the WordPress login screen (`/wp-login.php`)
/**
* Styles for the login screen
*/
function _login() {
wp_enqueue_style( 'login', get_template_directory_uri() . '/assets/css/login.css' );
}
add_action( 'login_enqueue_scripts', '_login' );
@jaredkc
jaredkc / newwindow.js
Created June 15, 2015 22:01
Open all external links in a new window
(function($) {
$(document).ready(function() {
/**
* Open all external links in a new window/tab
*/
$('a').each(function() {
var a = new RegExp('/' + window.location.host + '/');
if(!a.test(this.href)) {
@jaredkc
jaredkc / faq-post-type.php
Created December 16, 2014 22:13
Basic setup for FAQ custom post type in WordPress
<?php
/**
* Post type to manage a list of frequently asked questions.
*
* @package rho
*/
if (__FILE__ == $_SERVER['SCRIPT_FILENAME']) { die(); }
if ( ! class_exists( 'FAQ_Post_Type' ) ) :