Skip to content

Instantly share code, notes, and snippets.

View saifsultanc's full-sized avatar
🏠
Remote

Saif Sultan saifsultanc

🏠
Remote
View GitHub Profile
@saifsultanc
saifsultanc / gw-conditional-read-only.php
Created February 26, 2025 01:47
gw-conditional-read-only.php
<?php
/**
* Gravity Wiz // Gravity Forms // Conditional Readonly Fields
* https://gravitywiz.com/
*
* This simple snippet will mark a field as readonly if a given source field has a specific value.
*
* Instructions:
*
* 1. Install this snippet with our free Code Chest plugin.
@saifsultanc
saifsultanc / 76963.php
Created February 11, 2025 07:01
76963.php
<?php
add_filter( 'gppa_get_batch_field_html', 'capture_acf_address_new', 10, 6 );
function capture_acf_address_new( $html, $field, $form, $fields, $entry_id, $hydrated_field ) {
// Replace 5 with your form id and 3 with your ACF address field id
if ( $form['id'] != 6 && $field['id'] != 3 ) {
return $html;
}
// Replace 1 with the field id of the field you have used for Field Value Object
$post_id = rgpost( 'input_1' );
@saifsultanc
saifsultanc / gspc-map-fields-to-checkout.php
Created February 10, 2025 13:44
gs-product-configurator/gspc-map-fields-to-checkout.php
<?php
add_action( 'woocommerce_before_customer_object_save', function( $customer ) {
static $already_updated = false;
if ( $already_updated || ! is_checkout() ) {
return;
}
$cart_items = WC()->cart->get_cart();
@saifsultanc
saifsultanc / gspc-process-entries-on-hold.php
Last active February 6, 2025 16:41
gspc-process-entries-on-hold.php
<?php
/**
* Gravity Shop // GS Product Configurator // Trigger feeds when payment is on hold.
*
* By default, feeds are only triggered when the payment is processing or complete.
*
* Instructions:
* 1. Install per https://gravitywiz.com/documentation/how-do-i-install-a-snippet/
* 2. Update `$payment_methods`, `$forms`, and `$do_not_process_feeds` accordingly.
*/
@saifsultanc
saifsultanc / gw-advanced-merge-tags.php
Last active February 7, 2025 02:56
CUSTOM gravity-forms/gw-advanced-merge-tags.php
<?php
/**
* Gravity Wiz // Gravity Forms // Advanced Merge Tags
*
* Adds support for several advanced merge tags:
* + post:id=xx&prop=xxx
* retrieve the desired property of the specified post (by ID)
* + post_meta:id=xx&meta_key=xxx
* retrieve the desired post meta value from the specified post and meta key
* + get() modifier
@saifsultanc
saifsultanc / gw-populate-acf-to-gf-address-for-field-value-object.php
Created February 3, 2025 17:24
gw-populate-acf-to-gf-address-for-field-value-object.php
<?php
add_filter( 'gppa_get_batch_field_html', 'capture_acf_address', 10, 6 );
function capture_acf_address( $html, $field, $form, $fields, $entry_id, $hydrated_field ) {
// Replace 5 with your form id and 3 with your ACF address field id
if ( $form['id'] != 5 && $field['id'] != 3 ) {
return $html;
}
$field_id = $field->id;
$value_1 = isset( $_POST['input_' . $field_id . '.1'] ) ? $_POST['input_' . $field_id . '.1'] : '';
<?php
class GPAA_Single_Line_Input {
private $_args = array();
public function __construct( $args = array() ) {
$this->_args = wp_parse_args( $args, array(
'form_id' => false,
'address_field_id' => false,
@saifsultanc
saifsultanc / gw-populate-acf-to-gf-address.php
Created January 27, 2025 13:22
Populate ACF Map Address back to GF Address field
<?php
add_filter( 'gppa_get_input_values', function ( $value, $field, $template, $objects ) {
$parts = array_map( 'trim', explode( ',', $value ) );
$field_id = $field['id'];
preg_match( '/^' . preg_quote($field_id, '/') . '\.(\d+)$/', $template, $matches );
$tag = $matches[1];
switch( $tag ) {
case '1': // Street Address
$value = $parts[9];
@saifsultanc
saifsultanc / gw-use-html5-datepicker-with-gpld.js
Last active January 23, 2025 07:29
gw-use-html5-datepicker-with-gpld.js
jQuery(document).ready(function($) {
var onlyConvertOnMobile = false; // Change to false if you wish for all devices to use HTML5 datepicker
var isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
if ( isMobile || onlyConvertOnMobile === false ) {
let $datepicker = $('#input_GFFORMID_1'); // Replace 1 with your field ID
// Ensure Gravity Forms' Datepicker is Destroyed
if ($datepicker.hasClass('hasDatepicker')) {
@saifsultanc
saifsultanc / gcgs-process-feeds-partial-entry.php
Created December 25, 2024 05:50
gcgs-process-feeds-partial-entry.php
<?php
/**
* Gravity Perks // GP Google Sheets // Process Feed when Partial Entry is Saved.
*
* Process Google Sheet feeds when a partial entry is saved.
*/
add_action( 'gform_partialentries_post_entry_saved', 'send_to_google_sheet_on_partial_entry_saved', 10, 2 );
function send_to_google_sheet_on_partial_entry_saved( $partial_entry, $form ) {
if ( function_exists( 'gp_google_sheets' ) ) {
$partial_entry['status'] = 'partial';