Skip to content

Instantly share code, notes, and snippets.

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

Pramod Jodhani pramodjodhani

🏠
Working from home
  • 09:13 (UTC +05:30)
View GitHub Profile
@pramodjodhani
pramodjodhani / functions.php
Created April 22, 2026 07:16
Disable Orderable ASAP settings for Local Pickup shipping method.
<?php
/**
* Disable Orderable ASAP settings for Local Pickup shipping method.
*/
add_action( 'orderable_location_object_init', function( $location ) {
// Only run on the frontend/checkout and ensure WooCommerce is active.
if ( is_admin() || ! function_exists( 'WC' ) || ! WC()->session ) {
return;
}
if ( ! class_exists( 'Orderable_Services' ) ) {
@pramodjodhani
pramodjodhani / functions.php
Created April 15, 2026 16:46
Kadence theme - change icon colors in the admin
<?php
/**
* Kadence theme - change icon colors in the admin
*/
function kadence_admin_change_icon_color() {
?>
<style>
svg {
/* todo: replace black with the color of your choice */
--kadence-color: black !important;
@pramodjodhani
pramodjodhani / functions.php
Created April 15, 2026 11:00
Orderable - by default set the date field to "Select a date.."
<?php
// Orderable - by default set the date field to "Select a date.."
add_action( 'wp_footer', function() {
?>
<script>
(function() {
let hasCleared = false;
let observer = null;
let userPickedDate = false;
@pramodjodhani
pramodjodhani / functions.php
Last active April 15, 2026 07:29
Orderable set minimum limit for addon checkbox
<?php
function orderable_set_minimum_selection() {
?>
<script>
/**
* Orderable: Enforce Minimum Selections for Checkbox Addons
*
* Instructions:
* 1. Update the 'minSelections' object below.
* 2. Use the exact Title of your field as the key.
@pramodjodhani
pramodjodhani / functions.php
Created March 20, 2026 07:45
Iconic Sales booster: Frequently bought together - link product images.
<?php
/**
* Iconic Sales booster: Frequently bought together - link product images.
*/
// 1) AJAX: return permalink for a given product ID.
add_action( 'wp_ajax_iconic_wsb_fbt_get_permalink', 'iconic_wsb_fbt_get_permalink' );
add_action( 'wp_ajax_nopriv_iconic_wsb_fbt_get_permalink', 'iconic_wsb_fbt_get_permalink' );
function iconic_wsb_fbt_get_permalink() {
$product_id = isset( $_POST['product_id'] ) ? absint( $_POST['product_id'] ) : 0;
@pramodjodhani
pramodjodhani / functions.php
Last active March 18, 2026 08:15
Prevent Flux Stepper from advancing to the next step if EU VAT number is invalid (BTW number validation)
<?php
/**
* Prevent Flux Stepper from advancing to the next step if EU VAT number is invalid.
*/
add_filter( 'flux_checkout_check_for_inline_errors', 'flux_validate_eu_vat_number', 10, 1 );
function flux_validate_eu_vat_number( $messages ) {
// Check if fields were sent in the AJAX request
if ( ! isset( $_POST['fields'] ) || ! is_array( $_POST['fields'] ) ) {
return $messages;
}
@pramodjodhani
pramodjodhani / functions.php
Created March 9, 2026 05:55
Prevent Flux Stepper from advancing to the next step if EU VAT number is invalid.
<?php
/**
* Prevent Flux Stepper from advancing to the next step if EU VAT number is invalid.
*/
add_filter( 'flux_checkout_check_for_inline_errors', 'flux_validate_eu_vat_number', 10, 1 );
function flux_validate_eu_vat_number( $messages ) {
// Check if fields were sent in the AJAX request
if ( ! isset( $_POST['fields'] ) || ! is_array( $_POST['fields'] ) ) {
return $messages;
}
@pramodjodhani
pramodjodhani / functions.php
Last active February 26, 2026 07:34
Add Orderable time slot and date to a given order ID.
<?php
/**
* Add Orderable time slot and date to a given order ID.
*
* @param int $order_id The WooCommerce Order ID.
* @param string $date The Date (e.g., '2026-02-26').
* @param string $time The Time (e.g., '10:00 - 11:00' or '10:00').
* @param string $service_type The Service Type (e.g., 'delivery' or 'pickup'). Default 'delivery'.
* @return bool True if successful, false otherwise.
*/
@pramodjodhani
pramodjodhani / function.php
Created February 23, 2026 06:10
Restrict Orderable service dates if a specific product is in the cart.
<?php
/**
* Restrict Orderable service dates if a specific product is in the cart.
*
* @param array|bool $service_dates The currently available service dates.
* @param string $type The service type ('delivery' or 'pickup').
* @param Orderable_Location_Single $location The location instance.
* @return array|bool
*/
function orderable_restrict_service_dates( $service_dates, $type, $location ) {
@pramodjodhani
pramodjodhani / function.php
Created February 19, 2026 06:52
Iconic Product configurator - compatibility with Avada theme's swatches.
<?php
/**
* Iconic Product configurator - compatibility with Avada theme's swatches.
*/
add_action( 'wp_footer', function() {
?>
<script>
jQuery(document).ready(function($) {
jQuery('.avada-color-select').click(function() {
const siblings = jQuery(this).siblings('.avada-select-parent');