Skip to content

Instantly share code, notes, and snippets.

View rajeshsingh520's full-sized avatar

Rajesh rajeshsingh520

View GitHub Profile
add_filter('pi_eqw_admin_email_id', function($email_id, $items, $email_obj){
if(isset($_POST['melyi-bemutatotermunk-van-kozelebb-onhoz']) &&
strpos($_POST['melyi-bemutatotermunk-van-kozelebb-onhoz'], 'Tatabánya') !== false ){
$email_id = '[email protected]';
}
return $email_id;
},10,3);
add_action( 'wp_enqueue_scripts', function () {
$js = "
jQuery(document).on('pi_add_to_enquiry_data', function(e, data){
if(jQuery('.wc-pao-addon-container').length == 0) return;
jQuery('.wc-pao-addon-container').each(function(){
var label = jQuery('.wc-pao-addon-name', this).text().trim();
var price = jQuery('input', this).val().trim();
if(price != ''){
data['variation_detail'][label] = price;
}
@rajeshsingh520
rajeshsingh520 / gist:4814ec13d942c7eb19ed54fd4f0ddf55
Created October 27, 2025 01:11
show sales popup only to logged in user
add_filter('pi_live_sales_notification_control_filter', function($show){
if( ! is_user_logged_in() ) {
return false;
}
return $show;
});
add_action( 'wp_enqueue_scripts', function(){
if(function_exists('is_checkout') && is_checkout()){
wp_dequeue_script( 'wc-opayopi-dropin' );
wp_deregister_script( 'wc-opayopi-dropin' );
}
}, PHP_INT_MAX );
@rajeshsingh520
rajeshsingh520 / gist:f00a217435b4f471a422dfee08e5d89f
Created October 21, 2025 09:24
configure different preparation time by day of the week
add_filter('pisol_dtt_setting_filter_pi_order_preparation_days', function($preparation_days) {
$day = (int) wp_date('w'); // 0 => sunday, 1 => monday
if($day == 0) return 2;
if($day == 6) return 3;
return $preparation_days;
});
@rajeshsingh520
rajeshsingh520 / gist:e97df3c5cd4db25c7aaa8caa1a26405f
Created October 17, 2025 02:14
disable date and time plugin for multiple categories
class pisol_custom_disable_20221118 {
private $disable_for_cats = [];
function __construct($cats) {
$this->disable_for_cats = is_array($cats) ? $cats : [$cats];
add_filter('pisol_disable_dtt_completely', [$this, 'disable']);
}
function disable($return) {
$only_special_cat_present = true;
@rajeshsingh520
rajeshsingh520 / gist:1ec3424bfdd522e5e871aad9d74ac3e7
Last active October 14, 2025 09:05
custom dropdown based on delivery or pickup
class Pi_DTT_Delivery_Packaging_Option {
private static $instance = null;
private function __construct() {
// Checkout dropdown
add_action( 'woocommerce_after_order_notes', [ $this, 'add_dropdown_field' ] );
// Save value
add_action( 'woocommerce_checkout_create_order', [ $this, 'save_order_meta' ], 10, 2 );
@rajeshsingh520
rajeshsingh520 / gist:ee93d55d2a5929d6a2dda4d049d0831c
Created October 9, 2025 01:04
Get ip country from cloudflare
add_filter('pi_dpmw_get_ip_country', function( $country ) {
if ( isset( $_SERVER['HTTP_CF_IPCOUNTRY'] ) && ! empty( $_SERVER['HTTP_CF_IPCOUNTRY'] ) ) {
return sanitize_text_field( $_SERVER['HTTP_CF_IPCOUNTRY'] ); // e.g. "US", "IN"
}
return $country; // fallback to original if Cloudflare header missing
});
add_action('woocommerce_after_shop_loop_item', function(){
global $product;
$product_id = $product->get_id();
$redirect_url = $product->get_permalink();
if(!empty($redirect_url)){
echo sprintf('<a href="%s" class="button readmore">Read more</a>', esc_url($redirect_url));
}
});
@rajeshsingh520
rajeshsingh520 / gist:f873a501f72b1898b7e315ca3f36a529
Created October 3, 2025 01:26
getting timeslot based on zone id
class zone_data_custom{
public $zone_value = array();
public $zone_id = 0;
public $date = '';
function __construct($date, $zone_id){
$zone_id = intval($zone_id);