Skip to content

Instantly share code, notes, and snippets.

View joePichardo's full-sized avatar

Joe Pichardo joePichardo

  • Phoenix, Arizona
View GitHub Profile
@joePichardo
joePichardo / countdown_timer_shopify_section.liquid
Created December 12, 2022 13:45
Countdown Timer - Shopify Section
{%- if section.blocks.size > 0 -%}
{%- for block in section.blocks -%}
{%- case block.type -%}
{%- when 'html' -%}
{%- if block.settings.enable_promo -%}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jQuery.Marquee/1.5.0/jquery.marquee.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.4.1/jquery.easing.min.js"></script>
<script>
$(function() {
$('.marquee').marquee({
@joePichardo
joePichardo / shopify-use-case-option-selection.html
Created September 28, 2020 14:27
Shopify option_selection.js usage
{{ 'option_selection.js' | shopify_asset_url | script_tag }}
<script>
// <![CDATA[
var selectCallback = function(variant, selector) {
if (variant) {
if (variant.available) {
// Selected a valid variant that is available.
$('#add-to-cart-button').removeClass('disabled').removeAttr('disabled').html('Add to Cart');
} else {
@joePichardo
joePichardo / shopify-script-free-product-with-coupon.rb
Last active September 17, 2020 16:43
Shopify Script for free product with coupon code - Free product is the least expensive
if Input.cart
FREEBIE_PRODUCT_PRICE = Money.zero
FREEBIE_PRODUCT_ID = 0
coupon_codes = Array["anniversary25", "coupon2", "coupon3"]
if Input.cart.discount_code != nil
if coupon_codes.include?(Input.cart.discount_code.code)
if Input.cart.line_items.size > 1
Input.cart.line_items.select do |line_item|
if FREEBIE_PRODUCT_PRICE == Money.zero
FREEBIE_PRODUCT_PRICE = line_item.variant.price
@joePichardo
joePichardo / shopify-liquid-navigation-with-bootstrap-4.liquid
Created August 30, 2020 12:10
Shopify Liquid navigation using Bootstrap 4
<nav class="navbar sticky-top navbar-expand-lg navbar-dark bg-primary">
<div class="container">
<a class="navbar-brand" href="{{ routes.root_url }}">Joe Pichardo</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
@joePichardo
joePichardo / bonfire-where-do-i-belong.js
Created December 10, 2015 22:15
Return the lowest index at which a value (second argument) should be inserted into an array (first argument) once it has been sorted. For example, where([1,2,3,4], 1.5) should return 1 because it is greater than 1 (index 0), but less than 2 (index 1).
// Bonfire: Where do I belong
// Author: @joepichardo
// Challenge: http://www.freecodecamp.com/challenges/bonfire-where-do-i-belong
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function where(arr, num) {
// Find my place in this sorted array.
var indexOfNum;
//sort from lowest to highest
@joePichardo
joePichardo / bonfire-seek-and-destroy.js
Created December 10, 2015 21:38
You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments.
// Bonfire: Seek and Destroy
// Author: @joepichardo
// Challenge: http://www.freecodecamp.com/challenges/bonfire-seek-and-destroy
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function destroyer(arr) {
// Remove all the values
//get other values (arguments) that are put into the parameters of destroyer
var removeChars = Array.prototype.slice.call(arguments);
@joePichardo
joePichardo / bonfire-falsy-bouncer.js
Created December 10, 2015 06:47
Remove all falsy values from an array. Falsy values in javascript are false, null, 0, "", undefined, and NaN.
// Bonfire: Falsy Bouncer
// Author: @joepichardo
// Challenge: http://www.freecodecamp.com/challenges/bonfire-falsy-bouncer
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function bouncer(arr) {
// Don't show a false ID to this bouncer.
function noFalsyVals(value){
//function used in conjunction with filter() function
//compares falsy values and returns value if none are found
@joePichardo
joePichardo / bonfire-mutations.js
Created December 10, 2015 06:29
Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array.
// Bonfire: Mutations
// Author: @joepichardo
// Challenge: http://www.freecodecamp.com/challenges/bonfire-mutations
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function mutation(arr) {
/*
compareChars is made into an array of lowerCase letters
compareToString is the string to compare the letters with and it is lowercased
@joePichardo
joePichardo / bonfire-slasher-flick.js
Created December 10, 2015 05:51
Return the remaining elements of an array after chopping off n elements from the head.
// Bonfire: Slasher Flick
// Author: @joepichardo
// Challenge: http://www.freecodecamp.com/challenges/bonfire-slasher-flick
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function slasher(arr, howMany) {
// it doesn't always pay to be first
//howMany is the number we must remove from our array of arr
@joePichardo
joePichardo / bonfire-chunky-monkey.js
Created December 10, 2015 05:31
Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a multidimensional array.
// Bonfire: Chunky Monkey
// Author: @joepichardo
// Challenge: http://www.freecodecamp.com/challenges/bonfire-chunky-monkey
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function chunk(arr, size) {
// Break it up.
//two empty arrays to make a two dimensional array
var outerArray = [];