Skip to content

Instantly share code, notes, and snippets.

View rajeshsingh520's full-sized avatar

Rajesh rajeshsingh520

View GitHub Profile
add_shortcode('pisol_generate_iframe', function ($atts) {
$main_domain = 'https://checkout.billsby.com/subscription?data-billsby-company=alldata';
$params = $_GET;
$iframe_url = add_query_arg($params, $main_domain);
return '<iframe src="' . esc_url($iframe_url) . '" width="100%" height="600px" frameborder="0"></iframe>';
});
@rajeshsingh520
rajeshsingh520 / block-time-on-specific-date.php
Created July 20, 2024 01:21
Block time range or time slot for specific date , you can give the time range of blocking
class custom_code_block_time_on_date{
static $instance = null;
static $block_on_date = '2024/07/31';
static $block_start_time = '10:00';
static $block_end_time = '12:00';
add_filter('pisol_dtt_setting_filter_pi_type', function( $type ){
if ( ! did_action( 'wp_loaded' ) ) return $type;
if(function_exists('WC') && isset(WC()->cart) && is_object(WC()->cart) ){
$products = WC()->cart->get_cart();
foreach($products as $product){
if(isset($product['wcsatt_data'])){
return 'Delivery';
}
add_filter('pi_dtt_date_generator', function($dates){
// Get the current date and day of the week using WordPress's current_time() function
$today = new DateTime(current_time('Y-m-d'));
$dayOfWeek = $today->format('w'); // Get the day of the week (0 = Sunday, 6 = Saturday)
$dates = []; // Initialize the dates array
if ($dayOfWeek == 6) {
// If today is Saturday, no dates should be shown
return $dates;
add_action('wp_enqueue_scripts', function(){
$js = '
jQuery(function($){
jQuery(document).on("change", ".pisol-location-radio, select[name=\'pickup_location\']", function () {
setTimeout(function(){
localStorage.removeItem("pisol_pickup_location");
}, 1);
});
});
';
add_filter('pisol_cefw_cart_total', function($total, $cart, $fee_arg, $fees){
foreach($fee_arg as $fee_detail){
$total += $fee_detail['amount'];
}
return $total;
}, 10, 4);
add_action('wp_enqueue_scripts', function () {
if(is_cart()) return;
wp_dequeue_script('pisol-mmq-amount');
wp_deregister_script('pisol-mmq-amount');
}, 100);
@rajeshsingh520
rajeshsingh520 / change-preparation-days.php
Last active July 6, 2024 01:08
This code set the preparation days to 2 days when it is saturday and user selected the delivery type "Delivery"
add_filter('pisol_dtt_setting_filter_pi_order_preparation_days', function($preparation_days){
$type = pi_dtt_delivery_type::getType();
$today = current_time('Y/m/d');
$todays_day = date('w', strtotime($today));
if(($todays_day == 6 || $todays_day == 5) && $type == 'pickup'){
if(class_exists('pisol_pldt_location')){
$location = pisol_pldt_location::getSavedPickupLocation();
if($location != 5073){
@rajeshsingh520
rajeshsingh520 / disable-pickup-for-category.php
Last active June 17, 2024 00:31
This allows you to disable pickup option when product from specific categories are in the cart, in below example we have used category 19, 36
add_filter('pisol_dtt_setting_filter_pi_type', function( $val ){
$disable_pickup_for_category = [19];
if ( ! did_action( 'wp_loaded' ) ) return 'Both';
if(function_exists('WC') && isset(WC()->cart) && is_object(WC()->cart)){
foreach( WC()->cart->get_cart() as $cart_item ) {
$product_in_cart = $cart_item['product_id'];
add_action('wp_enqueue_scripts', function () {
$inline_script = "
jQuery(document).ready(function($) {
jQuery(document).on('pisol_enquiry_cart_count', function(e, count){
jQuery('.dashicons-cart').html('<span>'+count+'</span>');
});
});
";
$custom_css = '