Skip to content

Instantly share code, notes, and snippets.

View claygriffiths's full-sized avatar

Clay Griffiths claygriffiths

View GitHub Profile
@claygriffiths
claygriffiths / gpef-sync-tax-rate-with-wc.php
Created June 28, 2020 03:18
GP eCommerce Fields: Sync Tax Field Rate with WooCommerce Tax Rate
<?php
/**
* Note: See https://gravitywiz.com/documentation/how-do-i-install-a-snippet/ for details on how to install snippets.
*
* The following snippet will the specified tax field to use the rate from a specified WooCommerce tax class.
*
* Instructions:
* * Set $form_id
* * Set $tax_field_id
* * Set $wc_tax_rate_id
@claygriffiths
claygriffiths / gf-product-addons-exclude-product.php
Last active June 27, 2020 21:32
WooCommerce Gravity Forms Product Add-ons: Exclude Product
<?php
/**
* Note: See https://gravitywiz.com/documentation/how-do-i-install-a-snippet/ for details on how to install snippets.
*
* This snippet allows you to prevent product fields from being added to the price of a product added to the WooCommerce
* cart via Gravity Forms Product Add-ons
*/
function gwiz_exclude_product_from_wc_product_addons( $product_name ) {
add_filter( 'gform_product_info', function ( $product_info ) use ( $product_name ) {
$products = $product_info['products'];
@claygriffiths
claygriffiths / gp-populate-anything-plus-gp-limit-choices.php
Created June 27, 2020 21:17 — forked from spivurno/gp-populate-anything-plus-gp-limit-choices.php
Gravity Perks // GP Populate Anything + GP Limit Choices
<?php
add_action( 'init', function() {
$gplc_form_id = 123;
$gplc_field_id = 4;
if( is_callable( 'gp_limit_choices' ) ) {
add_filter( "gform_pre_process_{$gplc_form_id}", function( $form ) {
@claygriffiths
claygriffiths / gpef-exclude-tax-fields-in-cart.php
Created June 27, 2020 16:18
GP eCommerce Fields + Gravity Forms Product Add-ons for WooCommerce: Exclude Tax Fields
<?php
/**
* Note: See https://gravitywiz.com/documentation/how-do-i-install-a-snippet/ for details on how to install snippets.
*
* Normally, GP eCommerce Fields Tax fields will be treated as Gravity Forms products when passed to WC Product Add-ons.
* If WooCommerce is configured to handle taxes, passing the tax fields will result in double-taxation.
*
* This snippet prevents the tax fields/product from being added to WooCommerce cart.
*
* Use case: Display the tax on the product page to help show the customer a tax
@claygriffiths
claygriffiths / gw-gravity-forms-set-entry-created-by.php
Last active June 20, 2020 14:17 — forked from spivurno/gw-gravity-forms-set-entry-created-by.php
Gravity Wiz // Gravity Forms // Set Entry's "created_by" Property to Field Value
<?php
/**
* Gravity Wiz // Gravity Forms // Set Entry's "created_by" Property to Field Value
*
* Can be used in combination with the [GW Populate Users](https://gist.github.com/spivurno/03205e87b8196b5a87cd) snippet
* to set the selected user as the creator of the entry.
*
* @version 1.0
* @author David Smith <david@gravitywiz.com>
* @license GPL-2.0+
<?php
/**
* Gravity Wiz // Gravity Forms // Double Confirmation Fields
*
* Require a field's value to be entered twice to confirm it.
*
* @version 0.3
* @author David Smith <david@gravitywiz.com>
* @license GPL-2.0+
* @link http://gravitywiz.com/custom-field-confirmation/
@claygriffiths
claygriffiths / gp-limit-choices-field-groups.php
Last active May 18, 2020 02:32 — forked from spivurno/gp-limit-choices-field-groups.php
Gravity Perks // GP Limit Choices // Field Groups
<?php
/**
* Gravity Perks // GP Limit Choices // Field Group
*
* Specify a group of fields that should create a unique choice to limited. For example, a Date field and Radio Button field could be
* combined to sell x tickets per date where the ticket type is controlled by the Radio Button field and the date is
* selected in the Date field.
*
* @version 1.3
* @author David Smith <david@gravitywiz.com>
@claygriffiths
claygriffiths / gw-gravity-forms-rounding.php
Last active May 5, 2020 03:36 — forked from spivurno/gw-gravity-forms-rounding.php
Gravity Wiz // Gravity Forms // Rounding by Increment
<?php
/**
* Gravity Wiz // Gravity Forms // Rounding by Increment
*
* Provides a variety of rounding functions for Gravity Form Number fields powered by the CSS class setting for each field. Functions include:
*
* + rounding to an increment (i.e. increment of 100 would round 1 to 100, 149 to 100, 150 to 200, etc) | class: 'gw-round-100'
* + rounding up by an increment (i.e. increment of 50 would round 1 to 50, 51 to 100, 149 to 150, etc) | class: 'gw-round-up-50'
* + rounding down by an increment (i.e. increment of 25 would round 1 to 0, 26 to 25, 51 to 50, etc) | class: 'gw-round-down-25'
* + rounding up to a specific minimum (i.e. min of 50 would round 1 to 50, 51 and greater would not be rounded) | class: 'gw-round-min-50'
@claygriffiths
claygriffiths / gw-require-list-columns.php
Created April 30, 2020 03:01 — forked from spivurno/gw-require-list-columns.php
Gravity Wiz // Require All Columns of List Field
<?php
/**
* Require All Columns of List Field
* http://gravitywiz.com/require-all-columns-of-list-field/
*/
class GWRequireListColumns {
private $field_ids;
public static $fields_with_req_cols = array();
@claygriffiths
claygriffiths / gw-gravity-forms-calculated-shipping.php
Created April 29, 2020 04:05 — forked from spivurno/gw-gravity-forms-calculated-shipping.php
Gravity Wiz // Gravity Forms // Calculated Shipping
<?php
/**
* Gravity Wiz // Gravity Forms // Calculated Shipping
*
* A simple method for using a calculated product field as a shipping field. This provides the ability to use
* calculations when determining a shipping price.
*
* @version 1.2
* @author David Smith <david@gravitywiz.com>
* @license GPL-2.0+