Skip to content

Instantly share code, notes, and snippets.

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

Pramod Jodhani pramodjodhani

🏠
Working from home
  • 17:27 (UTC +05:30)
View GitHub Profile
@pramodjodhani
pramodjodhani / functions.php
Created February 14, 2024 08:05
Flux checkout - disable address autofill by browser
/**
* Flux checkout - disable autofill.
*
* @return void
*/
function iconic_flux_disable_autofill_address() {
if ( ! is_checkout() ) {
return;
}
@pramodjodhani
pramodjodhani / gravityforms.php
Created February 6, 2024 08:55
Add a custom merge tag {custom_today_ymd}
<?php
// Create a custom merge tag for gravity forms.
add_filter( 'gform_custom_merge_tags', 'pj_add_custom_merge_tags', 10, 4 );
function pj_add_custom_merge_tags( $merge_tags, $form_id, $fields, $element_id ) {
$merge_tags[] = array( 'label' => 'Today date(Y-M-D)', 'tag' => '{custom_today_ymd}' );
return $merge_tags;
}
// Add a custom merge tag to the list of available merge tags in the form editor.
add_filter( 'gform_merge_tags', 'pj_add_custom_merge_tag', 10, 4 );
@pramodjodhani
pramodjodhani / functions.php
Created January 29, 2024 05:18
Flux checkout - hide shipping section for details and address step.
<?php // do not include this line to functions.php
/**
* Flux checkout - hide shipping section for details and address step.
*/
function flux_hide_shipping_section_for_details_address_step() {
if ( ! is_checkout() ) {
return;
}
?>
@pramodjodhani
pramodjodhani / functions.php
Created January 24, 2024 06:32
Iconic WDS - compatiblity with CartFlows.
/**
* Iconic WDS - compatiblity with CartFlows.
*/
add_action(
'wp_footer',
function() {
if ( ! is_checkout() ) {
return;
}
?>
<?php //do not add this line to functions.php
/**
* Iconic WDS - modify same day cut off time for certain categories.
*/
function iconic_wds_modify_same_day_cutoff_for_categories( $cut_off ) {
// todo - change the categories.
$categories_a = array( 'pizza' );
$categories_b = array( 'bread' );
global $iconic_wds;
@pramodjodhani
pramodjodhani / functions.php
Created January 18, 2024 09:08
Iconic WDS - disable timeslot for specific products.
/**
* Iconic WDS - disable timeslot for specific products.
*
* @return bool
*/
function iconic_wds_disable_timeslot_for_specific_products( $disabled ) {
// todo replace with your product ids.
$disable_for_products = array( 10 );
if ( only_these_products_are_in_cart( $disable_for_products ) ) {
@pramodjodhani
pramodjodhani / functions.php
Created January 16, 2024 06:45
WDS - open date picker by default
<?php // do not add this line to functions.php
/**
* Iconic Delivery slots - open date picker by default on page load.
*/
function iconic_wds_trigger_delivery_date_focus() {
if ( ! is_checkout() ) {
return;
}
?>
@pramodjodhani
pramodjodhani / functions.php
Created January 11, 2024 06:49
Multi Currency for Gravity forms - set currency based on browser language instead of IP
<?php
/**
* Multi currency - set currency based on browser language.
*
* @return void
*/
function idea_multi_set_currency_based_on_browser_lang() {
?>
<script>
(function() {
@pramodjodhani
pramodjodhani / functions.php
Created January 3, 2024 07:24
WDS - divi compatiblity
<?php
/**
* Iconic WDS - compatibility with Divi Checkout modules.
*/
add_action(
'init',
function() {
remove_action( 'woocommerce_after_checkout_validation', array( 'Iconic_WDS_Checkout', 'catch_shipping' ), 10, 2 );
}
);
@pramodjodhani
pramodjodhani / script.js
Created December 27, 2023 07:56
JS function to convert decimal number to binary
/*
JS function to convert decimal number to Binary
*/
function decimal_to_binary( num ) {
var div = 0;
var res = [];
do {
div = parseInt(num/2);
var remainder = num % 2;