Skip to content

Instantly share code, notes, and snippets.

View joshuaiz's full-sized avatar
💭
it iz what it iz

Joshua Michaels joshuaiz

💭
it iz what it iz
View GitHub Profile
@joshuaiz
joshuaiz / product-atc-options.js
Last active June 21, 2023 18:49
Shopify Add To Cart with options
const handleAddToCart = (e) => {
e.preventDefault()
if (
productOptions.embroidery === true &&
productOptions.embroiderySubmitted === false
) {
setEmbroideryError(true)
alert(
'Please select all required embroidery options and submit before adding to your cart.'
@joshuaiz
joshuaiz / prepopulate-gf-radio.php
Created May 19, 2017 14:29
Pre-populate Gravity Forms Dropdown
<?php
add_filter( 'gform_pre_render_2', 'populate_posts' );
add_filter( 'gform_pre_validation_2', 'populate_posts' );
add_filter( 'gform_pre_submission_filter_2', 'populate_posts' );
add_filter( 'gform_admin_pre_render_2', 'populate_posts' );
function populate_posts( $form ) {
foreach ( $form['fields'] as &$field ) {
if ( strpos( $field->cssClass, 'populate-posts' ) === false ) {
/* GC */
let gcDataArray = []
let gcCachedData = JSON.parse(localStorage.getItem('ma_pgc'))
// when customer adds physical gift card(s) to the cart
$('body').on('click', '.add-to-cart-physical', function () {
let notes = ''
console.log('atc pgc clicked')
@joshuaiz
joshuaiz / scss_css_liquid.sh
Created May 31, 2020 04:51
Append processed css from .scss file to .liquid file with the same name
# Script for CodeKit hook to append processed css from scss file to liquid file
# (make sure to use 'Compressed' for scss->css output so everything is on one line)
#
# To use:
# 1. create a `/styles` directory in your Shopify theme for your .scss files
# 2. name the .scss file the same name as the liquid file; e.g. sample.scss/sample.liquid
# 3. IMPORTANT: add empty `<style></style>` tags to first line of liquid file; add empty line below
# 4. add this script to your project in CodeKit in Hooks
# 5. profit
@joshuaiz
joshuaiz / wpmdb_clear_wp_super_cache.php
Created September 30, 2018 02:58
WordPress: Clear WP Super Cache after WP Migrate DB Pro migration
<?php
// Add this to your functions.php file of the active theme
add_action( 'wpmdb_migration_complete', 'wpmdb_clear_wp_super_cache', 2, 20 );
function wpmdb_clear_wp_super_cache() {
if (function_exists('wp_cache_clear_cache')) {
wp_cache_clear_cache();
}
}
@joshuaiz
joshuaiz / plate-body-class.php
Last active April 22, 2018 01:52
Plate WordPress body class function: adds more classes to your WordPress posts + pages to help with CSS
<?php
// Body Class functions
// Adds more slugs to body class so we can style individual pages + posts.
// In your SCSS/CSS, use .page-yourslug {} to add styles for that page or post.
add_filter( 'body_class', 'plate_body_class' );
function plate_body_class( $classes ) {
global $post;
@joshuaiz
joshuaiz / quicktags.php
Created April 9, 2018 21:19
Add extra Quicktags to WordPress Content box
<?php
/*
* QUICKTAGS
*
* Let's add some extra Quicktags for clients who aren't HTML masters
* They are pretty handy for HTML masters too.
*
* Hook into the 'admin_print_footer_scripts' action
*
*/
@joshuaiz
joshuaiz / jsx-wrap-comment.sublime-snippet
Last active March 5, 2018 01:22
Wrap selected text in JSX style comment
<snippet>
<!-- Wraps selected text in JSX style comment, e.g. {/* <Component /> */} -->
<!-- Save this to ~/Application Support/Sublime Text 3/Packages/User/ -->
<!-- You'll need to add a keybinding in Sublime Text > Preferences > Key Bindings -->
<!-- {
"keys": ["alt+command+j"],
"command": "insert_snippet",
"args": { "name": "Packages/User/jsx-wrap-comment.sublime-snippet" }
} -->
<content><![CDATA[
@joshuaiz
joshuaiz / liquidsass.sublime-snippet
Last active February 9, 2018 05:03
Sublime liquid sass/scss interpolation. Use this to select elements in a scss.liquid file and use sass interpolation to escape them so you can use a preprocessor.
<!-- Save to ~/Library/Application Support/Sublime Text 3/Packages/User/ -->
<!-- Example: if you have some liquid like: {{ settings.site_bg_col }}; in your .scss.liquid file,
select that (except for the closing ; and use the keybinding set below. -->
<!-- Output: #{" {{ settings.site_bg_col }} "}; -->
<snippet>
<content><![CDATA[
#{" $SELECTION "}
]]></content>
<!-- this tab trigger won't really work when using $SELECTION -->
@joshuaiz
joshuaiz / update-limit-choices-value.php
Created August 24, 2017 06:50
Attempt to update GF Limit Choices value when user profile is updated (not working)
<?php
// just a sample function to see what's going on
// not tied to a particular action yet
// we are on a user profile edit screen
add_action( 'wp', function() {
$form_id = 4; // GF user registration form
$choice_field_id = 13; // ACF 'time_slots' field
$choice_value = ''; // initializing the variable (otherwise PHP 7 freaks out)
$field_key = "field_5996299aee5a9"; // ACF 'time_slots' field