Skip to content

Instantly share code, notes, and snippets.

View claygriffiths's full-sized avatar

Clay Griffiths claygriffiths

View GitHub Profile
@claygriffiths
claygriffiths / gwiz-validate-html-field-in-form-editor.js
Created September 27, 2023 20:22
GWiz: Validate HTML Fields in Form Editor
// Paste this into your browser DevTools console while editing a form in Gravity Forms
// Load fast-xml-parser
jQuery.getScript(
"https://cdnjs.cloudflare.com/ajax/libs/fast-xml-parser/4.0.8/fxparser.js",
function () {
// Loop through HTML fields in window.form.fields
window.form.fields.forEach(function (field) {
if (field.type !== "html") {
return;
}
@claygriffiths
claygriffiths / sticky-scrollbar.css
Last active August 7, 2023 17:17
Gravity Wiz Redesign: Sticky Scrollbar
.table-of-contents {
position: sticky;
top: 2.25rem;
overflow-y: auto;
max-height: calc(100vh - 2.25rem);
margin-top: 2.25rem;
padding-bottom: 2.25rem;
box-sizing: border-box;
}
@claygriffiths
claygriffiths / gspc-map-form-fields-to-checkout.php
Created August 4, 2023 21:45
GS Product Configurator: Map form fields to checkout
<?php
add_filter('woocommerce_checkout_get_value', function( $input, $key ) {
// Get current items in the cart.
$cart_items = WC()->cart->get_cart();
// Loop through cart items.
foreach ( $cart_items as $cart_item ) {
// Convert to a GSPC Cart Item
$gspc_cart_item = \GS_Product_Configurator\WC_Cart_Item::from( $cart_item );
@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 / gspc-populate-field-with-order-id.php
Last active July 10, 2023 16:08
GS Product Configurator: Populate Field with Order ID
<?php
/**
* Gravity Shop // GS Product Configurator // Populate Gravity Forms field with WooCommerce Order ID
*
* Populate fields in a Gravity Form that is linked to a WooCommerce product using GS Product Configurator
* with the WooCommerce order ID after checking out.
*
* Credit: Rochelle Victor (https://github.com/rochekaid)
*
* Instructions:
@claygriffiths
claygriffiths / gfoai-fine-tuned-sep.php
Created December 27, 2022 20:51
Gravity Forms OpenAI: Custom Separator for Fine-Tuned Models
<?php
/**
* Gravity Wiz // Gravity Forms OpenAI // Add separator to prompt
* https://gravitywiz.com/path/to/article/
*
* Adds a separator to a prompt if needed by a fine-tuned model.
*
* Instructions:
* 1. Customize $model and $sep accordingly.
*/
<?php
/**
* Gravity Wiz // Gravity Forms // Set Number of List Field Rows by Field Value
*
* Add/remove list field rows automatically based on the value entered in the specified field. Removes the add/remove
* that normally buttons next to List field rows.
*
* @version 1.1
* @author David Smith <david@gravitywiz.com>
* @license GPL-2.0+
@claygriffiths
claygriffiths / nested-entries.php
Last active June 27, 2022 21:30
GP Nested Forms: Template that hides Nested Entries table if empty
<?php
/**
* This template is based off of gp-nested-forms/templates/nested-entries.php
*
* Any modifications from the original have been noted.
*
* ==== Installation: ====
*
* 1. Place this file in your theme under gp-nested-forms/nested-entries.php. The full path should look something like
* wp-content/themes/YOUR-THEME/gp-nested-forms/nested-entries.php
@claygriffiths
claygriffiths / gpns-custom-recurring-schedule.php
Last active March 8, 2022 20:00
GP Notification Scheduler: Set Recurring Schedule to Every 6 Months
<?php
/**
* Gravity Perks // GP Notification Scheduler // Set Recurring Schedule to Every 6 Months
* https://gravitywiz.com/documentation/gravity-forms-notification-scheduler
*
* Instructions:
* * Install snippet per https://gravitywiz.com/documentation/how-do-i-install-a-snippet/
* * Update $form_id, $notification_id, and if required, $desired_time
*/
add_filter( 'gpns_schedule_timestamp', function ( $timestamp, $notification, $entry, $is_recurring, $current_time ) {
@claygriffiths
claygriffiths / gpaa-autocomplete-cities.js
Created March 8, 2022 01:43
GP Address Autocomplete: Show Cities as Results
/**
* Gravity Perks // GP Address Autocomplete // Show Cities as Results
* https://gravitywiz.com/documentation/gravity-forms-address-autocomplete
*
* Instructions:
* 1. Install our free Custom JavaScript for Gravity Forms plugin.
* Download the plugin here: https://gravitywiz.com/gravity-forms-custom-javascript/
* 2. Copy and paste the snippet into the editor of the Custom Javascript for Gravity Forms plugin.
* 3. Install accompanying gpaa-autocomplete-cities.php snippet
*/