Skip to content

Instantly share code, notes, and snippets.

@jimmijazz
jimmijazz / Filtering variant options
Created July 7, 2022 08:39
Filtering variant options
/* MTBD Product filtering solution *
This could all be done in liquid as well
Add a product-options id to the fieldset
*/
var options = [[], [], [], []];
var optionsFieldSet = document.getElementById("product-options");
var fieldSetInputs = optionsFieldSet.getElementsByTagName("input");
{
"query": "mutation publishablePublish($id: ID!, $input: [PublicationInput!]!) { publishablePublish(id: $id, input: $input) { publishable { availablePublicationCount publicationCount publishedOnCurrentPublication } shop { id } userErrors { field message } }}",
"variables": {
"id": "gid://shopify/Product/{{product.legacyResourceId}}",
"input": [{ "publicationId": "gid://shopify/Publication/25658064918" }]
}
}
@jimmijazz
jimmijazz / Add to Cart Prompt Message (Jake)
Last active November 10, 2022 00:06
Add to Cart Prompt Message (Jake)
{%- assign has_bib = false -%}
{%- assign has_jersey = false -%}
{%- assign has_bundle = false -%}
{%- for item in cart.items -%}
{% if item.product.type == 'Bib' -%}
{%- assign has_bib = true -%}
{%- elsif item.product.type == 'Jersey' -%}
{%- assign has_jersey = true -%}
{%- endif -%}
@jimmijazz
jimmijazz / Add to Cart with AJAX Add to Cart(Jake)
Last active November 10, 2022 00:06
Add to Cart with AJAX Add to Cart(Jake)
<!-- This code will add an item to the cart on button click. -->
{%- assign has_bib = false -%}
{%- assign has_jersey = false -%}
{%- assign has_bundle = false -%}
{%- for item in cart.items -%}
{% if item.product.type == 'Bib' -%}
{%- assign has_bib = true -%}
{%- elsif item.product.type == 'Jersey' -%}
@jimmijazz
jimmijazz / index.js
Created February 3, 2023 22:38
Capture payment for Active Subscribers based on charge_delay and when their order was created
/* Customer orders are recieved as "authorized". The number of days left in their trial is passed as a line
item prop charge_delay. This cron job checks each hour for any orders that are still in authorized state.
If the (order date + charge_delay) is > current date, their trial has ended and we capture payment if
they are still have the "Active Subscriber" tag.
*/
async function captureUnpaidOrders() {
console.log('Debug: Getting unpaid orders');
/* Finds any orders where financial status is authorized.
Then checks if the created_at date + the charge_delay is less than the current date.
@jimmijazz
jimmijazz / Shopify Script Discounting
Last active January 21, 2024 16:09
Shopify Script Discounting example
# ================================ Customizable Settings ================================
# ================================================================
# Tiered Discounts by Quantity
#
# A list of discount tier offers where:
# - 'product_selector_match_type' determines whether we look for
# products that do or don't match the entered selectors. Can
# be:
# - ':include' to check if the product does match
# - ':exclude' to make sure the product doesn't match