Skip to content

Instantly share code, notes, and snippets.

View pramodjodhani's full-sized avatar
🏠
Working from home

Pramod Jodhani pramodjodhani

🏠
Working from home
  • 23:51 (UTC +05:30)
View GitHub Profile
@pramodjodhani
pramodjodhani / functions.php
Created May 9, 2024 14:34
Multi-currency for Gravity Forms - allow functioning without OpenExchangeRates API.
<?php
/**
* Multi-currency for Gravity Forms - allow without OpenExchangeRates API.
*/
function gf_multi_currency_allow_without_exchange_rates_api() {
?>
<script>
if ( gform?.addFilter ) {
gform.addFilter( 'idea_mcg_exchange_rates', function() {
return {
@pramodjodhani
pramodjodhani / functions.php
Created May 7, 2024 07:56
Flux checkout - display businesses in the address search.
<?php
/**
* Flux checkout - display businesses in the address search.
*
* Add this JS snippet right before flux-checkout script.
*/
add_filter( 'script_loader_tag', function( $tag, $handle, $src ) {
if ( 'flux-checkout' !== $handle ) {
return $tag;
}
@pramodjodhani
pramodjodhani / functions.php
Created May 1, 2024 06:05
Flux checkout - disable address fields for local pickup shipping method.
<?php
/**
* Flux checkout - disable address fields for local pickup shipping method.
*
* @return void
*/
function flux_disable_fields_for_local_pickup() {
$wc_ajax = filter_input( INPUT_GET, 'wc-ajax' );
if ( ! Iconic_Flux_Core::is_checkout( true ) && 'checkout' !== $wc_ajax ) {
@pramodjodhani
pramodjodhani / functions.php
Last active April 30, 2024 04:14
Gravity forms stripe - charge custom amount
<?php
add_filter( 'gform_stripe_charge_pre_create', function ( $charge, $feed, $submission_data, $form, $entry ) {
// Enter the amount in cents. 600 = $6.00.
$charge['amount'] = 600;
return $charge;
}, 10, 5);
@pramodjodhani
pramodjodhani / functions.php
Created April 26, 2024 07:51
flux - custom field validation on JS side
/**
* Flux checkout birthday field custom validation.
*/
add_action( 'wp_footer', function() {
?>
<script>
jQuery( function($) {
$( 'form.checkout' ).on( 'blur', '.birthday-field input', function() {
// todo change your validation logic here.
@pramodjodhani
pramodjodhani / mcg-change-currency.js
Created April 26, 2024 04:19
MCG - Change currency when tab is changed.
/**
* Multi-currency for Gravity Forms.
* Change currency when tab is changed.
*/
jQuery( document ).ready( function () {
jQuery( document ).on( 'click', '#e-n-tabs-title-2461', function () {
gf_global.gf_currency_config = idea_mcg.all_currencies[ 'CAD' ];
$( ".gform_wrapper input" ).trigger( 'change' );
} )
@pramodjodhani
pramodjodhani / functions.php
Created April 17, 2024 08:54
Iconic WDS - thank you page - change the position of edit timeslot.
<?php
/**
* Iconic WDS - TY page - change the position of edit timeslot.
*
* @return void
*/
function iconic_wds_change_position_of_edit_timeslot_ty_page() {
remove_action( 'woocommerce_order_details_after_order_table', array( 'Iconic_WDS_Edit_Timeslots', 'maybe_display_checkout_fields' ), 10 );
add_action( 'woocommerce_before_thankyou', array( 'Iconic_WDS_Edit_Timeslots', 'maybe_display_checkout_fields' ), 10 );
}
@pramodjodhani
pramodjodhani / functions.php
Created April 5, 2024 06:52
WooCommerce change new customer's auto generated username format.
<?php
/**
* Custom new username for new customer.
*
* @param string $username Username.
* @param string $email Email.
* @param array $new_user_args New user args.
* @param string $suffix Suffix.
*
* @return string
@pramodjodhani
pramodjodhani / function.php
Last active April 4, 2024 06:55
Flux - move the position of shipping section in classic theme
<?php
/**
* Move shiping section for classic theme.
*
* @param array $step Step data.
*
* @return void
*/
function move_shipping_section_after_shipping_address( $step ) {
if ( 'payment' === $step['slug'] ) {
@pramodjodhani
pramodjodhani / functions.php
Created April 1, 2024 05:12
Iconic WDS GCal - do not include first name and last name in the event address
<?php
/**
* Iconic WDS GCal - do not include the first and last name in the event address.
*
* @param string $location Location.
* @param array $order Order.
*
* @return string
*/
function iconic_wds_gcal_change_location( $location, $order ) {