Skip to content

Instantly share code, notes, and snippets.

View hirejordansmith's full-sized avatar

Jordan Smith hirejordansmith

View GitHub Profile
@hirejordansmith
hirejordansmith / base-code.js
Last active April 27, 2020 12:19
How to automatically reload a Gravity Form in a modal
// This would be added to a callback or event function
// Replace "82" with the ID of your form
var gwrf = window.gwrf_82;
if( typeof gwrf != 'undefined' ) {
gwrf.reloadForm();
}
@hirejordansmith
hirejordansmith / add-support-merge-tags-gravity-form-labels.php
Created May 28, 2016 11:32
How to Add Support for Merge Tags in Gravity Form Labels
<?php
/**
* Gravity Wiz // Gravity Forms // Add Support for Merge Tags in Gravity Form Labels
* https://gravitywiz.com/add-support-for-merge-tags-gravity-form-labels/
*/
add_filter( 'gppc_replace_merge_tags_in_labels', '__return_true' );
@hirejordansmith
hirejordansmith / add-coupon-dynamically-based-on-cart-subtotal-woocommerce.php
Last active December 10, 2019 21:07
Add A Coupon Dynamically based on Cart Subtotal with WooCommerce
<?php
/**
* @snippet Add A Coupon Dynamically based on Cart Subtotal with WooCommerce
* @sourcecode http://hirejordansmith.com
* @author Jordan Smith
* @compatible WooCommerce 2.4.7
*/
add_action( 'woocommerce_before_cart', 'apply_matched_coupons' );
@hirejordansmith
hirejordansmith / functions.php
Last active August 28, 2019 19:54
Move ACF Field Groups back to High (after title) position
<?php
add_action( 'admin_init', 'prefix_reset_metabox_positions' );
function prefix_reset_metabox_positions(){
// for posts
delete_user_meta( wp_get_current_user()->ID, 'meta-box-order_post' );
// for pages
delete_user_meta( wp_get_current_user()->ID, 'meta-box-order_page' );
// for custom post type Sermon Series
@hirejordansmith
hirejordansmith / functions.php
Created June 28, 2019 03:24
How to add a WooCommerce Quick Buy Link without a plugin
<?php
// Outputs the button below the default Add to cart button on Single Product page
add_action('woocommerce_after_add_to_cart_button','hjs_add_quick_buy_link_single', 5);
function hjs_add_quick_buy_link_single() { ?>
<style>
.woocommerce div.product form.cart .button.quick-buy {
background: #f04e3d !important;
border-color: #f04e3d !important;
margin-left: 10px;
}
@hirejordansmith
hirejordansmith / hjs-gform-pre-submission-css-class.php
Created April 4, 2019 19:13
Gravity Forms // gform_pre_submission filter based on field CSS class
<?php
add_action( 'gform_pre_submission', 'pre_submission_handler_one' );
function pre_submission_handler_one( $form ) {
foreach ( $form['fields'] as $field ) {
$cssClass = $field->cssClass;
if ( strpos($cssClass, 'test') !== false) {
$field_id = $field->id;
$date = new DateTime( 'now' );
$_POST["input_$field_id"] = $date->format('U');
}
@hirejordansmith
hirejordansmith / change-upsell-products-per-row-woocommerce.php
Created October 14, 2016 12:46
How to change upsell products per row for WooCommerce
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_upsells', 15 );
if ( ! function_exists( 'woocommerce_output_upsells' ) ) {
function woocommerce_output_upsells() {
woocommerce_upsell_display( 5,5 ); // Display 5 products in rows of 5
}
}
@hirejordansmith
hirejordansmith / css-bounce.css
Created October 14, 2016 09:49
CSS Animations
@-moz-keyframes bounce {
0%, 20%, 50%, 80%, 100% {
-moz-transform: translateY(0);
transform: translateY(0);
}
40% {
-moz-transform: translateY(-30px);
transform: translateY(-30px);
}
60% {
@hirejordansmith
hirejordansmith / replace-woocommerce-product-archive-add-to-cart-button.php
Last active March 7, 2019 09:56
Replace WooCommerce Product Archive Add to Cart Button
<?php
// This just returns an empty value for the archive product button
add_filter( 'woocommerce_loop_add_to_cart_link', 'change_add_to_cart_loop' );
function change_add_to_cart_loop( $product ) {
global $product; // this may not be necessary as it should have pulled the object in already
return '';
}
// Then we add a new button with the same WooCommerce Markup that links directly to the product page
add_action( 'woocommerce_after_shop_loop_item', 'hjs_loop_add_to_cart', 10 );
@hirejordansmith
hirejordansmith / replace-ajax-spinner-with-custom-spinner.css
Created August 11, 2016 21:05
Replace AJAX Spinner with Custom Spinner
/*
hourglass.gif replaces the default AJAX spinner
http://loading.io/ <- Good place to find a new one
*/
body img.gform_ajax_spinner {
position: fixed !important;