Skip to content

Instantly share code, notes, and snippets.

View martinsoender's full-sized avatar

Martin Søndergaard martinsoender

View GitHub Profile
@martinsoender
martinsoender / component-cart-drawer.liquid
Last active January 11, 2024 09:27
Shopify Cart Drawer
{% comment %} Globals {% endcomment %}
{%- liquid
assign country_code = blank
if request.host contains '.messyweekend.'
assign country_code = request.host | split: '.' | first
else
assign country_code = request.host | split: '.' | last
endif
-%}
@martinsoender
martinsoender / index.html
Created June 12, 2023 11:22
Vuetify Data Table Column Multi-Select Filter w/ Autocomplete Search
<div id="app">
<v-app id="inspire">
<v-data-table
v-model="selected"
:headers="headers"
:items="filteredDesserts"
show-select
item-key="name"
>
<template v-slot:header="{ header }">
@martinsoender
martinsoender / index.html
Created March 20, 2023 15:29
Isotope - combination filters with 4 selects with reset, disable non available
<div class="container">
<div class="row">
<div class="zone filter clearfix">
<div class="col-md-2">
<h3>Color</h3>
<label>
<select data-filter-group="color" class="data-selector">
<option class="filter-all" data-filter="" selected> All </option>
<option data-filter=".red"> Red <span class="filter-count"></span></option>
<option data-filter=".yellow"> Yellow <span class="filter-count"></span></option>
@martinsoender
martinsoender / index.html
Created February 22, 2023 13:22
GTM - Add to cart event tracking for Shopify
<!-- Example button element. Note class "product-add-to-cart" is not all button elements -->
<button type="button" class="button button-green button-block product-add-to-cart">Add to cart</button>
<script>
// Global DataLayer declaration
window.dataLayer = window.dataLayer || [];
// Fetch all Add to cart button elements
var AddToCartButtons = document.querySelectorAll('.<GLOBAL_ATC_BUTTON_CLASS>');
@martinsoender
martinsoender / vertebrae-transaction-tracking.html
Created November 24, 2021 17:22
Vertebrae transaction script
<script>
window.$AXIS=window.$AXIS||function(){($AXIS.q=$AXIS.q||[]).push(arguments)};$AXIS.l=+new Date;
$AXIS('init', {
'clientId':'cca08230-da90-11eb-a86e-02766dea5d8a',
'environment':'prod'
});
// The addTransaction
$AXIS('ecommerce:addTransaction', {
@martinsoender
martinsoender / shopify-fb-tracking.liquid
Created November 22, 2021 09:14
Replace <insert_pixel_id> with the Facebook pixel id
{% if first_time_accessed %}
<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,'script',
@martinsoender
martinsoender / script.rb
Created November 15, 2021 16:17
Tiered Discounts By Spending Threshold
# Define spending thresholds, from lowest spend to highest spend.
SPENDING_THRESHOLDS = [
{
spend: 10000, # spend amount (in cents)
discount: 15 # percentage discount
},
{
spend: 20000,
discount: 20
},
{
"name": "Christopher Cloos",
"key": "cca08230-da90-11eb-a86e-02766dea5d8a",
"scoutfile": {
"url": "https://api.vertebrae-axis.com/tag/scoutfile/v1.25.1/bundle.js"
},
"objectViewer": {
"url": "https://api.vertebrae-axis.com/branch/objectViewer/feature/safari_15_fix/main.js"
},
"arButton": {
@martinsoender
martinsoender / shopifyCartQueue.js
Created July 5, 2021 18:40 — forked from davidemaser/shopifyCartQueue.js
Using the Shopify queue to add items to the cart
Shopify.queue = [];
Shopify.moveAlong = function() {
if (Shopify.queue.length) {
var request = Shopify.queue.shift();
Shopify.addItem(request.variantId, request.quantity, request.properties, Shopify.moveAlong);
}
else {
document.location.href = '/cart';
}
};
@martinsoender
martinsoender / README.md
Created June 6, 2021 19:18 — forked from ridem/README.md
Download a Shopify store's assets used in your theme

It's hard to migrate section themes that rely heavily on images. This bit of code helps you download all the CDN assets of your theme.

  1. Create a cdn_assets folder
  2. Create the download_assets.js file at the root of your project
  3. Edit the download_assets.js file to match the path to your settings_data.json (line 3)
  4. Edit the download_assets.js file to set the "CDN code" of your store. Each file that you upload from /admin/settings/files gets uploaded with the following format: https://cdn.shopify.com/s/files/1/YOUR_CDN_CODE/files/YOURFILE. The format of the code is /\d{4}\/\d{4}/ (four digits, a forward slash, and four digits)