Skip to content

Instantly share code, notes, and snippets.

View Wurren's full-sized avatar
🎯
Focusing

Warren Haskins Wurren

🎯
Focusing
View GitHub Profile
@Wurren
Wurren / example-grapqhl-fetch.js
Last active October 29, 2021 18:40
Example of using Graphql with Fetch
const queryFragment = `
query {
products(first: 10) {
edges {
node {
id
title
}
}
}
@Wurren
Wurren / cp-chat.html
Last active August 12, 2021 13:50
CP Chat
<!--Start of Zopim Live Chat Script-->
<script type="text/javascript">
window.$zopim || (function(d, s) {
var z = $zopim = function(c) {
z._.push(c)
},
$ = z.s =
d.createElement(s),
e = d.getElementsByTagName(s)[0];
z.set = function(o) {
@Wurren
Wurren / add-to-cart.js
Created February 7, 2020 12:20
Shopify Add to cart
document.addEventListener("DOMContentLoaded", function() {
const forms = Array.from(document.querySelectorAll("form.add_to_cart"));
forms.forEach(form => {
form.addEventListener("submit", e => {
e.preventDefault();
const button = form.querySelector("button");
const product_id = button.dataset["prod-id"];
fetch("/cart/add.js", {
method: "POST",
headers: {
@Wurren
Wurren / ajax.js
Last active June 20, 2018 10:15
Ajax Subscribe
$("#stepOne").on("submit", function(e) {
e.preventDefault();
// This is the shape of the data. Email and List_ID are required for every request
// the optional params are 'spa_wellness', 'family', 'exclusive_offers' and 'midweek_offers'
// the values for these are true or false. You can just submit only the true values if necessary.
// this below example is just an idea. Whatever way you want to post the data is up to you.
var initial_data = {
list_id: "XXXXX",
@Wurren
Wurren / console.save.js
Created January 28, 2016 15:28
Console Save JSON Output
(function(console){
console.save = function(data, filename){
if(!data) {
console.error('Console.save: No data')
return;
}
if(!filename) filename = 'console.json'
@Wurren
Wurren / choice.js
Last active October 2, 2015 20:08
Jquery Plugin Boilerplate
;(function ( $, window, document, undefined ) {
var pluginName = '',
document = window.document,
defaults ={};
function Plugin( element, options ) {
this.element = element;
this.options = $.extend( {}, defaults, options) ;