Skip to content

Instantly share code, notes, and snippets.

View rajeshsingh520's full-sized avatar

Rajesh rajeshsingh520

View GitHub Profile
@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;
});
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';
}