Skip to content

Instantly share code, notes, and snippets.

View resistorsoftware's full-sized avatar

David Lazar resistorsoftware

View GitHub Profile
@resistorsoftware
resistorsoftware / Meta Titler Gist with Settings
Created October 20, 2011 13:21
Meta-Titler Gist for themes with built in settings for Title and Description
{% assign maxwords = 30 %}
{% if template == 'product' %}
{% if collection %}
<link rel="canonical" href="{{ shop.url }}{{ product.url }}" />
{% endif %}
{% assign mf = product.metafields.meta_data %}
{% unless mf == empty %}
{% for mf in product.metafields.meta_data' %}
{% capture key %}{{ mf | first }}{% endcapture %}
{% if key == 'title' %}
@resistorsoftware
resistorsoftware / Google Shopping Snippet
Last active March 22, 2021 17:01
Enhanced Meta Tagger snippet
{% comment %}
- add this snippet to any product.liquid template, at the top of the file, and you can access the extra data provided by
the new version of Meta Tagger that supports Google Shopping.
{% endcomment %}
{% if template contains 'product' %}
{% if product.metafields.global %}
{% for mf in product.metafields.global %}
@resistorsoftware
resistorsoftware / product.liquid
Last active January 10, 2023 02:31
You Might Like This! Shopify Related Products App
<!--
* a simple HTML DOM element for rendering related products.
* Style with CSS to make the <ul> look like whatever you want.
* place this snippet in your product.liquid where you would like the related products to appear
-->
<div id="related-products-container">
<h1>YOU MIGHT LIKE THIS!</h1>
<div id="related">
<ul class="related">
@resistorsoftware
resistorsoftware / theme.meta-titler.liquid
Created June 24, 2011 02:16
A Liquid Snippet for the Meta-Titler Shopify App
{% capture title %}<title>{{ shop.name }} &#124; {{ page_title }}</title>{% endcapture %}
{% if template == 'product' %}
{% assign mf = product.metafields.meta_data %}
{% unless mf == empty %}
{% for mf in product.metafields.meta_data' %}
{% capture key %}{{ mf | first }}{% endcapture %}
{% if key == 'title' %}
{% capture title %}<title>{{mf | last}}</title>{% endcapture %}
<meta name="title" content="{{mf | last}}" />
{% endif %}
@resistorsoftware
resistorsoftware / API burn
Created June 12, 2011 00:24
Simple 2-API call burn
order = ShopifyAPI::Order.find(id)
order.note = "Go ride a bike and stop being a whiny twerp."
order.save
@resistorsoftware
resistorsoftware / DJ
Created June 11, 2011 21:05
Elegant Delayed Job for Shopify
# here comes 1, 2, 200, or even 603 id's
get '/orders/do_it_man/?' do
if ShopifyAPI.credit_left > 0
Delayed::Job.enqueue(Hookah::Pipe.new(current_shop.site, params[:ids])) # <-- regular run, we have some credit...
else
Delayed::Job.enqueue(Hookah::Pipe.new(current_shop.site, params[:ids]), 0, 601.seconds.from_now) # <--- no credit, run later
end
end
module Hookah
@resistorsoftware
resistorsoftware / gist:1000968
Created May 31, 2011 17:55
how to write AR query to just show orders with a delivery date for an item
class UnfulfilledOrder < ActiveRecord::Base
belongs_to :shop
has_many :items, :dependent => :delete_all
end
class Item < ActiveRecord::Base
belongs_to :unfulfilled_orders
has_many :deliveries, :dependent => :delete_all
end
@resistorsoftware
resistorsoftware / Shopify API CLI
Created May 15, 2011 18:55
A simple way to take advantage of the Shopify API gem CLI
#!/usr/bin/env ruby
require 'rubygems'
require 'shopify_api'
require 'thor'
require 'abbrev'
require 'yaml'
module ShopifyAPI
class Cli < Thor
include Thor::Actions
@resistorsoftware
resistorsoftware / ShopifyAPICallLimit.rb
Created May 15, 2011 14:27 — forked from christocracy/ShopifyAPICallLimit.rb
Hacking ActiveResource::Connection for Shopify API in order to read HTTP response header 'http_x_shopify_api_call_limit'. Simply require this code after your gems have been loaded. Caveat emptor: This hack modifies a private method of AR::Connection; H
class ActiveResource::Connection
# HACK 1: Add an attr_reader for response
attr_reader :response
def request(method, path, *arguments)
result = ActiveSupport::Notifications.instrument("request.active_resource") do |payload|
payload[:method] = method
payload[:request_uri] = "#{site.scheme}://#{site.host}:#{site.port}#{path}"
payload[:result] = http.send(method, path, *arguments)
end
@resistorsoftware
resistorsoftware / ShopifyAPICallLimit.rb
Created May 14, 2011 16:01 — forked from christocracy/ShopifyAPICallLimit.rb
Hacking ActiveResource::Connection for Shopify API in order to read HTTP response header 'http_x_shopify_api_call_limit'. Simply require this code after your gems have been loaded.
class ActiveResource::Connection
# HACK 1: Add an attr_reader for response
attr_reader :response
def request(method, path, *arguments)
result = ActiveSupport::Notifications.instrument("request.active_resource") do |payload|
payload[:method] = method
payload[:request_uri] = "#{site.scheme}://#{site.host}:#{site.port}#{path}"
payload[:result] = http.send(method, path, *arguments)
end