Skip to content

Instantly share code, notes, and snippets.

View rajeshsingh520's full-sized avatar

Rajesh rajeshsingh520

View GitHub Profile
add_action('wp_enqueue_scripts', function() {
wp_enqueue_script('jquery-ui-datepicker');
$custom_js = "
jQuery(function($){
if ($.datepicker && typeof $.datepicker.setDefaults === 'function') {
$.datepicker.setDefaults({
dayNamesMin: ['S','M','T','W','T','F','S']
});
add_filter('pisol_dtt_order_table_delivery_method', function($order_delivery_type, $delivery_method){
$mark = '<mark class="order-status status-%s"><span>%s</span></mark>';
if($delivery_method === 'pickup'){
$label = 'Pickup';
return sprintf($mark, 'processing', $label);
}elseif($delivery_method === 'delivery'){
$label = 'Delivery';
return sprintf($mark, 'completed', $label);
}else{
return '';
@rajeshsingh520
rajeshsingh520 / gist:5c6e64499f3be486ade1557bd4f05284
Last active February 25, 2026 10:01
register custom tool in the list of tools under woocommerce mcp server
class WCAbilitiesDemo {
/**
* Plugin version.
*/
public const VERSION = '1.0.0';
/**
* Initialize the plugin.
*/
@rajeshsingh520
rajeshsingh520 / gist:7f5a655a06fc1cefba898df1a3197c43
Created February 25, 2026 07:08
to see the available tools in woocommerce mcp server in python
import json
import httpx
URL = "https://landing.local/wp-json/woocommerce/mcp"
CK = "ck_a9bf627784b1d8d51c21ce6f52a0fd60f20b579e"
CS = "cs_0367a201dcea028c090dde0b88e619cf7df86329"
base_headers = {
"Content-Type": "application/json",
@rajeshsingh520
rajeshsingh520 / gist:adf85b6fbbb63551e5b581998cab26f7
Last active February 21, 2026 05:03
charge fees based on selected delivery time
if(defined('PI_CEFW_SELECTION_RULE_SLUG')){
class Pi_cefw_selection_rule_selected_time_between_time{
public $slug;
public $condition;
function __construct($slug){
$this->slug = $slug;
$this->condition = 'selected_time_between_time';
/* this adds the condition in set of rules dropdown */
add_filter('before_send_order_to_iconnect', function ($baseOrder) {
$order = wc_get_order($baseOrder->order_id);
if (!$order) return $baseOrder;
$piDate = $order->get_meta('pi_system_delivery_date', true);
$piTime = $order->get_meta('pi_delivery_time', true);
if(empty($piTime)){
$piTime = '21:00';
}
add_filter('before_send_order_to_iconnect', function ($baseOrder) {
$order = wc_get_order($baseOrder->order_id);
if (!$order) return $baseOrder;
$piDate = $order->get_meta('pi_delivery_date', true);
$piTime = $order->get_meta('pi_delivery_time', true);
$ts = '';
if (!empty($piDate) && !empty($piTime)) {
$timePart = trim(explode('-', (string) $piTime)[0]); // "10:00 - 10:30" -> "10:00"
add_filter('pisol_dtt_ics_default_start_time', function($time){
return '09:00';
}, PHP_INT_MAX);
add_filter('pisol_dtt_ics_default_end_time', function($time){
return '21:00';
}, PHP_INT_MAX);
class TwentyTwenty_Custom_Scripts {
private static $instance = null;
public $hide_field_name = 'delivery-address';
public static function get_instance() {
if ( is_null( self::$instance ) ) {
self::$instance = new self();
}
add_filter('pisol_dtt_setting_filter_pi_type', function($type){
$todays_date = current_time('Y/m/d');
$disable_delivery_date = '2026/02/16';
$cutoff_time = '13:00';
$current_time = current_time('H:i');
if($todays_date === $disable_delivery_date && strtotime($current_time) < strtotime($cutoff_time)){
return 'Pickup';
}
return $type;
}, PHP_INT_MAX);