Skip to content

Instantly share code, notes, and snippets.

View rajeshsingh520's full-sized avatar

Rajesh rajeshsingh520

View GitHub Profile
add_filter('pisol_cefw_fees_filter', function($fees){
foreach($fees as $key => $fee){
$original_amount = $fee['amount'];
$roundedNumber = floor($original_amount * 100) / 100;
$fees[$key]['amount'] = $roundedNumber;
}
return $fees;
},10,1);
class custom_code_20241213{
static $instance = null;
static $section = [
@rajeshsingh520
rajeshsingh520 / disable-date-time-completelly.php
Created December 19, 2024 11:02
disable dtt plugin completelly
class pisol_marp_disable_dtt_plugin_options_for_category{
function __construct(){
add_filter('pisol_disable_dtt_completely', array($this, 'disableDateTimePlugin'));
}
function disableDateTimePlugin($value){
if(is_admin()) return;
$disabe_for_cat = array(19); // Category id for which the plugin will be disabled
@rajeshsingh520
rajeshsingh520 / remove-pickup-location.php
Created December 18, 2024 02:01
remove selected pickup location
add_action('wp_enqueue_scripts', function(){
if(function_exists('WC') && isset(WC()->session) && is_object(WC()->session)){
WC()->session->set('pickup_location', null);
}
$js = '
jQuery(function($){
localStorage.removeItem("pisol_pickup_location");
});
';
<?php
add_filter('woocommerce_available_payment_gateways', function($gateways){
if(function_exists('WC') && isset(WC()->session) && is_object(WC()->session)){
WC()->session->set( 'stop_reload_do_ajax_again', null );
}
return $gateways;
}, PHP_INT_MAX);
@rajeshsingh520
rajeshsingh520 / change-position.php
Last active December 15, 2024 01:57
move option fee selector to top of order review table
add_action( 'wp_enqueue_scripts', function(){
if(function_exists('is_checkout') && !is_checkout()) return;
$js = '
jQuery(document).ready(function($){
function pisol_custom_changePosition(){
var selectedRow = jQuery("td.pi-condition-fees").parent();
selectedRow.prependTo("table.woocommerce-checkout-review-order-table thead");
class custom_code_20241213{
static $instance = null;
static $section = [
0 => [
'product_ids' => [201, 749, 564],
'dates' => ['2024/12/21', '2024/12/22', '2024/12/23', '2024/12/24', '2024/12/25'],
'disable_date_time' => '2024/12/21 12:00'
],
add_action('wp_enqueue_scripts', function(){
if(!is_product()) return;
$js = "
document.addEventListener('DOMContentLoaded', function () {
function attachChangeListeners() {
document.querySelectorAll('.pi-special-qty').forEach(function (element) {
// Remove any previously attached listener to avoid duplication
element.removeEventListener('change', handleChange);
// Attach the change event listener
add_filter('pisol_dtt_forced_time_slots', function($slots, $day, $date, $type){
if($type !== 'delivery') return $slots;
$cutoff_time = '17:00';
$next_day_allowed = '15:00';
$today = current_time('Y/m/d');
$current_time = current_time('H:i');
$next_date = date('Y/m/d', strtotime($today . ' +1 day'));
add_filter('pisol_cefw_cart_total', function($total, $cart){
$total = $cart->get_subtotal();
$tax_total = $cart->get_subtotal_tax();
$shipping = $cart->get_shipping_total();
$shipping_tax = $cart->get_shipping_tax();
return $total+$tax_total+$shipping+$shipping_tax;
},10,2);