Skip to content

Instantly share code, notes, and snippets.

View rajeshsingh520's full-sized avatar

Rajesh rajeshsingh520

View GitHub Profile
@rajeshsingh520
rajeshsingh520 / gist:1cefb9f38906a146c58745428e964563
Created May 15, 2026 10:05
move option fee selection to any place on checout page
class pisol_custom_clone_checkbox{
static $instance = null;
static $run = 0;
static function get_instance(){
if(is_null(self::$instance)){
self::$instance = new self();
}
@rajeshsingh520
rajeshsingh520 / gist:36d7228c70a97ea3c89d7e226c53d68a
Created May 13, 2026 12:25
show estimate date as a count of working days from today that is simple sum of (preparation days + shipping days)
add_filter('pisol_edd_product_estimate', function($estimate){
$min = (int) ($estimate['min_preparation_days'] ?? 0) + (int) ($estimate['min_shipping_days'] ?? 0);
$max = (int) ($estimate['max_preparation_days'] ?? 0) + (int) ($estimate['max_shipping_days'] ?? 0);
$estimate['min_days'] = $min;
$estimate['max_days'] = $max;
return $estimate;
});
add_filter('pisol_edd_get_order_estimate', function($estimate){
$min = (int) ($estimate['min_preparation_days'] ?? 0) + (int) ($estimate['min_shipping_days'] ?? 0);
@rajeshsingh520
rajeshsingh520 / gist:9e6c4cba74ca557bfa65db34166430cd
Last active May 9, 2026 01:25
This halves the shipping cost in the renewal order of the woocommerce subscription
add_action( 'wcs_renewal_order_created', 'pi_modify_renewal_shipping', 10, 2 );
function pi_modify_renewal_shipping( $renewal_order, $subscription ) {
foreach ( $renewal_order->get_items( 'shipping' ) as $item_id => $shipping_item ) {
$total = (float) $shipping_item->get_total();
$new_total = $total / 2;
@rajeshsingh520
rajeshsingh520 / gist:cb17b41a559ed6b23e78e2cb4d07e167
Last active May 15, 2026 04:34
option to hide enq button for product on the loop pages
class PIE_Disable_Archive_Enquiry {
private static $instance = null;
public $loop_product_enquiry_position;
public $add_to_enquiry_text_loop_variable;
public static function instance() {
return self::$instance ?: self::$instance = new self();
@rajeshsingh520
rajeshsingh520 / gist:f54a4273fbaee42b0833d4178dfccd80
Created April 30, 2026 05:40
code to make enquiry button work with ninja form table with variable product
add_action('wp_enqueue_scripts', function () {
wp_enqueue_script('jquery');
$inline_js = <<<'JS'
jQuery(document).on('pi_add_to_enquiry_data', function(e, data){
var id = data.id;
var form_id = '#nt_variation_form_' + id;
var qty = '#nt_product_qty_' + id;
if (jQuery(qty).length > 0) {
add_filter('pisol_edd_option_filter_pi_general_date_format', function($format){
return 'l';
});
@rajeshsingh520
rajeshsingh520 / gist:cf0b1eef446e3ec0bbb25aa7a02e9323
Created April 22, 2026 12:35
give discount when partial payment not selected
add_action('woocommerce_cart_calculate_fees', function($cart) {
if(class_exists('PISOL\DPMW\Session')){
$fees_selected = PISOL\DPMW\Session::partialPaymentSelectedInSession();
if(!$fees_selected){
$cart->add_fee( 'Custom Fee', -100 );
}
}
}, 20);
add_filter( 'woocommerce_shipping_package_name', function($name){
if(class_exists('pi_dtt_delivery_type')){
$type = pi_dtt_delivery_type::getType();
if($type == 'delivery'){
return 'Delivery';
}
}
return $name;
});
@rajeshsingh520
rajeshsingh520 / gist:3a80dbd94cbf0398f008594d5a563ed9
Last active April 16, 2026 07:11
Enquiry plugin working with YITH WooCommerce Product Add-ons & Extra Options
add_filter('pisol_eqw_product_price_filter', function($price, $product, $product_in_cart){
if(isset($product_in_cart['variation_detail']['price']) ){
$raw_price = $product_in_cart['variation_detail']['price'];
$clean_price = str_replace(',', '', $raw_price);
if(is_numeric($clean_price)){
return (float) $clean_price;
}
}
return $price;
@rajeshsingh520
rajeshsingh520 / gist:a520513a96a386941ea5c0295507ba91
Created March 11, 2026 10:52
order pickup location by name
add_filter('pisol_dtt_get_location', function($arg){
$arg['orderby'] = 'title';
$arg['order'] = 'ASC'; // ASC or DESC
return $arg;
});