Skip to content

Instantly share code, notes, and snippets.

View tpage99's full-sized avatar

Taylor Page tpage99

View GitHub Profile
@tpage99
tpage99 / updated-video-input.liquid
Last active March 3, 2023 22:04
Add Video Input Setting to Shopify Theme - Dawn v7.0.0 theme
{{ 'video-section.css' | asset_url | stylesheet_tag }}
{{ 'component-deferred-media.css' | asset_url | stylesheet_tag }}
{%- style -%}
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px;
padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px;
}
@media screen and (min-width: 750px) {
@tpage99
tpage99 / cart_api.js
Last active August 8, 2023 07:13
Cart API Frequently Used - Vanilla JS
// Always compare to the docs first: https://shopify.dev/docs/api/ajax/reference/cart
// Get the Cart
fetch("/cart.js")
.then((response) => response.json())
.then((data) => console.log(data));
// Add to Cart
let addToCartItem = {
items: [
@tpage99
tpage99 / random_number.liquid
Created October 3, 2023 20:26
Create a random number with Liquid for Customer Testimonials Metaobject
{% comment %}
my_reviews is an array of metaobjects assigned via metafields
{% endcomment %}
{% liquid
assign review_min = 1
assign review_max = my_reviews.size
assign mod_ref = review_max | minus: review_min
assign random_number = "now" | date: "%N" | modulo: mod_ref | plus: review_min
assign review = my_reviews[random_number]