Skip to content

Instantly share code, notes, and snippets.

View kmeister2000's full-sized avatar

Karl Meisterheim kmeister2000

View GitHub Profile
@kmeister2000
kmeister2000 / Checkout.jsx
Created April 12, 2024 18:07
A graphsql query and Checkout extension that brands the checkout header as described in Episode 20 of the Liquid Weekly Podcast
import {reactExtension, Image, InlineStack, InlineLayout, BlockStack, Button, View, Link} from '@shopify/ui-extensions-react/checkout';
export default reactExtension('purchase.checkout.header.render-after', () => (
return (
<InlineLayout columns={['fill','30%']} spacing="base">
<Image source="https://cdn.shopify.com/s/files/xxxxxxxx" />
<InlineLayout inlineAlignment="end" columns={["60%","fill"]} spacing="tight">
<Image source="https://cdn.shopify.com/s/files/xxxxxxx" />
<BlockStack inlineAlignment="start" spacing="extraTight">
@kmeister2000
kmeister2000 / shopify_get_blog_category_for_article
Last active March 31, 2023 17:35
Shopify - get the blog category for every article
{% comment %} By Stefan Bowerman and Gina Gregory {% endcomment %}
{% comment %} Shopify doesn't have a way to access article.blog directly so we have to parse out the url {% endcomment %}
{% assign blogHandle = article.handle | split: '/' | first %}
{% comment %}Access the blog object {% endcomment %}
{% blog = blogs[blog_handle] %}
@kmeister2000
kmeister2000 / shopify_update_metafields_from_spreadsheet
Created March 31, 2023 12:46
a Google Script to update Shopify metafields in bulk from a spreadsheet.
// Written by Brendan Quigley
// Three Acres - threeacres.ca
//
// Creates or Updates product metafields in bulk using the product handle
// Steps to use:
// 1. Create a private shopify app with product read & write permission
// 2. Install the private app to generate an access token
// 3. Paste the code into the script editor on a google sheet
// 4. Replace [ myshopify.com ] with the Shopify URL ( 3 Places )
// 5. Replace [ Access Token ] with the access token ( 3 Places )
@kmeister2000
kmeister2000 / quantity_discount.rb
Created November 9, 2018 18:52
Apply 30% discount to each item when purchasing 3 or more
return unless Input.cart.line_items.count < 3
Input.cart.line_items.each do |item|
item.change_line_price(item.line_price * .7, "Quantity discount applied!")
end
Output.cart = Input.cart
@kmeister2000
kmeister2000 / vip_customer_discount.rb
Created November 9, 2018 18:46
Add a 10% discount if the customer is tagged as 'vip'
is_vip = false
Input.customer.tags.each {|tag| is_vip = true if tag.name == "vip"}
return unless is_vip
Input.cart.line_items.each do |line_item|
product = line_item.variant.product
next if product.gift_card?
line_item.change_line_price(line_item.price * .9, message: "VIP Discount Applied!")
end
@kmeister2000
kmeister2000 / free_us_shipping.rb
Last active November 9, 2018 18:31
Apply free shipping if the address is in the US and the cart total is over $100
# Free US shipping when cart total exceeds $100
free_shipping_threshold = 100
if Input.cart.total >= Money.new(cents: (100 * free_shipping_threshold)) && Input.cart.shipping_address.country.include?("United States")
Input.shipping_rates.each do |shipping_rate|
next unless shipping_rate.source == "shopify"
shipping_rate.apply_discount(shipping_rate.price, message: "Free shipping")
end
end
@kmeister2000
kmeister2000 / README.md
Last active December 19, 2015 09:49 — forked from marksim/README.md

My script for pair sessions on my box.

What it does

  • downloads the appropriate ssh keys from github
  • punches a hole in my firewall (see Note #2)
  • copies the appropriate 'ssh pair@your-external-ip' command to your clipboard (see Note #1)
  • sets up the tmux session
  • cleans up the session, the keys and the firewall after it's done
@kmeister2000
kmeister2000 / tictactoe.rb
Created May 15, 2013 03:20
Pair Programming Session 1 - Tic Tac Toe
class TicTacToe
end
class Player
class << self
attr_accessor :players
def clear_players