Skip to content

Instantly share code, notes, and snippets.

Avatar

Nate Holland curiouscrusher

View GitHub Profile
@curiouscrusher
curiouscrusher / radio-options.liquid
Created Jun 14, 2018
Swap the select dropdowns for radio input types and retain full Slate compatibility
View radio-options.liquid
{% unless product.has_only_default_variant %}
{% for option in product.options_with_values %}
<div class="selector-wrapper js">
{%- assign i = forloop.index0 -%}
<h1>
{{ option.name }}
</h1>
{% for value in option.values %}
<input class="" id="SingleOptionSelector-{{ i }}-{{ value | handle }}" data-single-option-selector data-index="option{{ option.position }}" type="radio" name="SingleOptionSelector-{{ i }}" value="{{ value | escape }}"{% if option.selected_value == value %}checked="checked"{% endif %} {% unless current_variant.available %}disabled="disabled"{% endunless %} >
<label for="SingleOptionSelector-{{ i }}-{{ value | handle }}"><span>{{ value }}</span></label>
@curiouscrusher
curiouscrusher / re-order.liquid
Created May 16, 2018
Quickly create a re-order button on order.liquid
View re-order.liquid
{% assign reorder_url = "" %}
{% for line_item in order.line_items %}
{% capture reorder_url %}{{ reorder_url | append: line_item.variant_id | append: ':' | append: line_item.quantity | append: ',' }}{% endcapture %}
{% endfor %}
<a href="{{ '/cart/' | append: reorder_url }}" class="btn">reorder</a></td>
@curiouscrusher
curiouscrusher / metafields.json
Created Sep 13, 2017
Add multiple Metafields to a Shopify Product in one API call
View metafields.json
// PUT https://yourstorename.myshopify.com/admin/products/#{id}.json
{
"product": {
"metafields": [{
"namespace": "your_namespace",
"key": "your_key",
"value": "your_value",
"value_type": "string"
},
{
@curiouscrusher
curiouscrusher / customers.sql
Created May 4, 2017 — forked from leek/_Magento1_DeleteTestData.md
Magento - Delete All Test Data
View customers.sql
SET FOREIGN_KEY_CHECKS=0;
-- Customers
TRUNCATE `customer_address_entity`;
TRUNCATE `customer_address_entity_datetime`;
TRUNCATE `customer_address_entity_decimal`;
TRUNCATE `customer_address_entity_int`;
TRUNCATE `customer_address_entity_text`;
TRUNCATE `customer_address_entity_varchar`;
TRUNCATE `customer_entity`;
@curiouscrusher
curiouscrusher / strip-html-tags.php
Last active Jul 8, 2016
If you've ever dealt with Product exports of any kind during a migration, you've probably thought something like "Wouldn't it be nice if I could strip out all these HTML tags in here..." Well now you can! Grab this script, insert your CSV names, and off you go!
View strip-html-tags.php
<?php
$csvFileNoTags = "products-test.csv"; // Name your new CSV file
$f = fopen($csvFileNoTags, 'w'); // Create the CSV file from above
$export = strip_tags(file_get_contents("products.csv")); // Load the CSV file and strip all tags from it
fwrite($f, $export); // Write the new CSV
fclose($f); // Fin
?>
@curiouscrusher
curiouscrusher / dumpdatabases-mysql.sh
Created Dec 2, 2015
A quick shell script to dump all your databases and compress them.
View dumpdatabases-mysql.sh
USER="root"
PASSWORD=""
OUTPUT="/Users/yourusername/Sites"
ExcludeDatabases="Database|information_schema|performance_schema|mysql|sys"
databases=`mysql -u $USER -p$PASWORD -e "SHOW DATABASES;" | tr -d "| " | egrep -v $ExcludeDatabases`
for database in $databases; do
echo "Dumping database: $database"
mysqldump -u $USER -p$PASSWORD --databases $database > `date +%Y%m%d`.$database.sql | gzip $OUTPUT/`date +%Y%m%d`.$database.sql
@curiouscrusher
curiouscrusher / wp-multiple-post-type-query.php
Last active Aug 29, 2015
Wordpress query for multiple post types. Lets say you need to query 3 different post types, and load 1 post from each. Without diving headfirst into SQL and Unions, this is a simpler solution. While may not be the most efficient route, it does the job, and if you can spare less than a second of load/query time, it'll solve your problem.
View wp-multiple-post-type-query.php
<?php
// Add your post types to the array
$posttypes = array('post_type_1','post_type_3','post_type_3');
$randompost_typs = shuffle($posttypes);
$counter = count($posttypes);
// Add or remove additional post types as needed
for($i=0; $i<$counter;$i++) {
if($randompost_typs[$i]=='post_type_1') {
// I only wanted one post from each, but you can raise or lower the value if needed
$posts_per_page = 1;
@curiouscrusher
curiouscrusher / .zshrc-alias
Last active Oct 19, 2015
Some cool bash alias'
View .zshrc-alias
alias trash="rm -rf ~/.Trash"
alias sites="cd ~/Sites"
alias cc="rm -rf var/cache var/full_page_cache var/session"
alias apache="sudo apachectl restart"
alias brup="brew update && brew upgrade && brew cleanup && brew prune && brew doctor"
alias wordpress="wget http://wordpress.org/latest.tar.gz"
alias wp-cleanup="tar --strip-components=1 -xzvf latest.tar.gz && trash latest.tar.gz"
alias gut="git"
@curiouscrusher
curiouscrusher / _SGulpfile.js
Last active Aug 29, 2015
A simple Gulpfile for use with the _S Wordpress starter theme. Still working out a few naming conventions.
View _SGulpfile.js
// Load dependencies
var gulp = require('gulp' ),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
livereload = require('gulp-livereload'),
sourcemaps = require('gulp-sourcemaps');
// Config variables
var config = new (function(){
this.package = 'wp-content/themes/your-theme-name/',
@curiouscrusher
curiouscrusher / Search By Category Snippet
Last active Aug 29, 2015
A search box to show results only from a specified category in Wordpress
View Search By Category Snippet
<?php $category_id = get_cat_ID('Your Category'); ?>
<form id="yourformid" method="get" action="<?php bloginfo('url'); ?>">
<input type="text" name="s" id="s" size="20" placeholder="Search" />
<input type="hidden" name="cat" value="<?php echo $category_id; ?>" />
<input type="submit" value="Search" />
</form>