Skip to content

Instantly share code, notes, and snippets.

@dturton
dturton / gist:8959430
Last active August 29, 2015 13:56
split wordpress content into two columns at the more tag
$morestring = '<!--more-->';
$explode_content = explode( $morestring, $post->post_content );
$content_before = apply_filters( 'the_content', $explode_content[0] );
$content_after = apply_filters( 'the_content', $explode_content[1] );
@dturton
dturton / gulpfile.js
Created May 5, 2015 16:26
Gulp image resize/optimize
// require gulp plugins
var gulp = require('gulp');
var imageresize = require('gulp-image-resize');
var imagemin = require('gulp-imagemin');
var watermark = require("gulp-watermark");
var rename = require("gulp-rename");
var gulpif = require('gulp-if');
var paths = {
@dturton
dturton / webpack.config.js
Created May 13, 2016 23:24 — forked from learncodeacademy/webpack.config.js
Sample Basic Webpack Config
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
module.exports = {
context: __dirname,
devtool: debug ? "inline-sourcemap" : null,
entry: "./js/scripts.js",
output: {
path: __dirname + "/js",
filename: "scripts.min.js"
@dturton
dturton / gist:7d71edca96b5fb3805eb5af2d8604a32
Created August 6, 2016 23:33 — forked from kyleaparker/gist:7812970
Shopify Lockdown App: How to remove the "Continue as Guest" button from the login screen.
<!--In theme.liquid, change:-->
<meta content="0; url=/account/login?checkout_url={{ return_url }}" http-equiv="refresh" />
<!--to -->
<meta content="0; url=/account/login?return_url={{ return_url }}" http-equiv="refresh" />
<!-- In customers/login.liquid, give the submit button an ID of customerlogin, for example: -->
<iframe src="https://t.pepperjamnetwork.com/track?PROGRAM_ID=####&INT=DYNAMIC{% assign sub_total = 0 %}{% for line_item in line_items %} {% assign sub_total = line_item.line_price | plus: sub_total %}{% endfor %}{% assign sub_total = sub_total | append: '.00' %}{% assign discount = 0 &}{% assign discount_percentage = 1 %}{% if order.discounts_amount > 0 %}{% for eachdiscount in order.discounts %}{% if eachdiscount.type != "ShippingDiscount" %}{% assign discount = discount | plus: eachdiscount.total_amount %}{% endif %}{% endfor %}{% endif %}{% assign disBYsub = discount | divided_by: sub_total %}{% assign discount_percentage = 1 | minus: disBYsub %}{% for line_item in line_items %}{% assign sub_total = line_item.line_price | plus: sub_total %}{% endfor %}{% assign sub_total = sub_total | append: '.00' %}{% for line_item in line_items %}&ITEM_ID{{ forloop.index }}={% if variant.available %}{{ line_item.variant.id }}{% else %}{{ line_item.sku }}{% endif %}&ITEM_PRICE{{forloop.index}}={% assign afterDiscountPric
@dturton
dturton / Much much simpler option selector for Shopify
Created April 29, 2017 15:04 — forked from zakhardage/Much much simpler option selector for Shopify
Much simpler version of Shopify's option_selection.js for separating product options into their own dropdown menus.
<form action="/cart/add" method="post">
{% if product.variants.size > 1 %}
{% if product.options[0] %}
{% assign used = '' %}
<label for="select-one">{{ product.options[0] }}</label>
<select id='select-one' onchange="letsDoThis()">
{% for variant in product.variants %}
{% unless used contains variant.option1 %}
<option value="{{ variant.option1 }}">{{ variant.option1 }}</option>
{% capture used %}{{ used }} {{ variant.option1 }}{% endcapture %}
{% comment %}
To add a companion product to the cart automatically if a primary product is in cart:
1. Create a new link list under your Navigation tab.
2. In that link list, make the first link point to companion product.
3. Copy your link list handle where indicated at line 9
4. Set the minimum cart total required for the bonus product on line 10
{% endcomment %}
{% assign linklist = linklists['put-your-link-list-handle-here'] %}
{% assign min_total = 100 %}
discounted_product = 12275195905
products_needed = [592406273]
products_seen = []
Input.cart.line_items.each do |line_item|
product = line_item.variant.product
products_seen << product.id if products_needed.include?(product.id)
end
Input.cart.line_items.each do |line_item|
@dturton
dturton / Free Gift.rb
Created January 18, 2018 18:07 — forked from HillbergAndBerkIT/Free Gift.rb
Shopify Scripts
# See https://onlygrowth.com/blogs/posts/17-shopify-scripts-to-maximize-conversions for some helpful snippets
class FreeGift
def initialize(variant_id, minTotal, message, quantity = 1)
@variant_id = variant_id
@minTotal = minTotal
@message = message
@giftQuantity = quantity
end
# Get the total of the cart without the variant price being included
@dturton
dturton / kue-express
Created January 21, 2018 13:31
node.js kue and express
import kue from 'kue'
import express from 'express'
const app = express();
const jobs = kue.createQueue()
app.use('/api', kue.app);
app.get('/job', (req, res) => {