Skip to content

Instantly share code, notes, and snippets.

View rajeshsingh520's full-sized avatar

Rajesh rajeshsingh520

View GitHub Profile
@rajeshsingh520
rajeshsingh520 / gist:f9fb1922747b848c32b19bdad6ca8fd5
Created September 17, 2025 05:33
restrict pickup location by product category, if no restriction is set on some pickup location then it will be shown for all product
class pisol_dtt_custom_20250917 {
private static $instance = null;
const META_KEY = '_pisol_dtt_selected_categories';
private function __construct() {
add_action( 'add_meta_boxes', [ $this, 'add_meta_box' ] );
add_action( 'save_post', [ $this, 'save_meta' ] );
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_assets' ], PHP_INT_MAX );
add_filter('pisol_dtt_get_location', [$this, 'add_location_categories'], 10, 2);
@rajeshsingh520
rajeshsingh520 / gist:d0985cc593da5fab4d6b5c090d63b068
Created September 16, 2025 11:34
Order tag rule based on shipping method present in the order (it considers multi package order)
use PISOL\AAOT\ADMIN\Conditions\Base_Condition;
class Shipping_Method_20250916 extends Base_Condition {
public function __construct() {
parent::__construct();
}
public function get_id() {
return 'shipping_method_20250916';
}
@rajeshsingh520
rajeshsingh520 / gist:e4904ff5335b32724d242a8bc596bccc
Created September 10, 2025 07:27
Passes the estimate date plugin dates to Delivery date plugin
add_filter('pisol_dtt_date_sort', function($dates) {
$start_date = '';
if (function_exists('WC') && isset(WC()->cart) && is_object(WC()->cart)) {
foreach (WC()->cart->get_cart() as $cart_item) {
$product_id = $cart_item['product_id'];
$variation_id = $cart_item['variation_id'];
if(!empty($variation_id)){
$product_id = $variation_id;
}
if (class_exists('\PISOL\EDD\BASE\Product')) {
@rajeshsingh520
rajeshsingh520 / gist:9b77f96f9c5326f9641675cb459270de
Last active September 10, 2025 04:51
split printify package
if ( ! class_exists( 'Pisol_Split_Shipping_20250910' ) ) {
class Pisol_Split_Shipping_20250910 {
private static $instance = null;
private $shipping_class_id = 280; // Replace with your shipping class ID
private function __construct() {
add_filter( 'woocommerce_cart_shipping_packages', [ $this, 'split_packages' ], PHP_INT_MAX );
}
@rajeshsingh520
rajeshsingh520 / gist:3b25b95415cc7658ca763a70fe762d78
Created September 8, 2025 06:28
If a shipping method is present in more then one shipping package, then this will divide its shipping cost by no of packages where it is selected. this assume the shipping cost of this method is same in all the package
add_filter( 'woocommerce_shipping_packages', 'pisol_adjust_split_shipping', 20 );
function pisol_adjust_split_shipping( $packages ) {
$target_method_id = 'pisol_extended_flat_shipping:4710';
// Count packages containing the method
$count = 0;
foreach ( $packages as $pkg ) {
if ( isset( $pkg['rates'][ $target_method_id ] ) ) {
$count++;
}
@rajeshsingh520
rajeshsingh520 / gist:c72e18d52c3a5ca6e1c8ad31fdc9afc0
Created September 6, 2025 01:52
declare WooCommerce virtual product as non virtual so we dont disable date and time selector
add_filter( 'woocommerce_is_virtual', function( $is_virtual, $product ) {
$type = $product->get_type();
if ( $type === 'bundle' ) {
return false;
}
return $is_virtual;
}, PHP_INT_MAX, 2 );
add_shortcode( 'estimate_date_loop', function( $atts ) {
if ( isset( $atts['id'] ) ) {
$product = wc_get_product( intval( $atts['id'] ) ) ?: null;
} else {
global $product;
}
if ( ! ( $product instanceof WC_Product ) ) {
return '';
}
@rajeshsingh520
rajeshsingh520 / gist:dfcde469a71ad997915df3ebf8eed099
Created August 20, 2025 02:11
different background color for the days of the week based on the zone id
class pisol_custom_20250820{
static $instance = null;
public static function get_instance() {
if ( is_null( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
add_filter( 'woocommerce_package_rates', function( $rates, $package ) {
// Core method names to hide
$hide = array( 'flat_rate', 'free_shipping', 'local_pickup' );
foreach ( $rates as $rate_id => $rate ) {
foreach ( $hide as $method ) {
if ( strpos( $rate_id, $method ) !== false ) {
unset( $rates[ $rate_id ] );
}
}
@rajeshsingh520
rajeshsingh520 / gist:edd70ba2bc06698f078b21df7b7efb01
Created August 19, 2025 01:31
green circle around active daet
.ui-datepicker-calendar td a.ui-state-default {
background: green !important;
width:40px;
height:40px;
display:flex !important;
text-align:center !important;
justify-content:center;
align-items:center;
margin:auto;