Skip to content

Instantly share code, notes, and snippets.

View rajeshsingh520's full-sized avatar

Rajesh rajeshsingh520

View GitHub Profile
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')) {
add_filter('pisol_edd_get_product_data', function($data, $product_object){
$category_to_exclude = 25;
if(!is_object($product_object->product)) return $data;
$product_id = $product_object->product->is_type('variation') ? $product_object->product->get_parent_id() : $product_object->product->get_id();
// Only apply logic to products not in category ID 25
if ( has_term($category_to_exclude, 'product_cat', $product_id) ) {
add_action( 'wp_loaded', function () {
if ( is_admin() || WC()->cart->is_empty() ) {
return;
}
$category_id = 106;
$quantity_in_category = 0;
foreach ( WC()->cart->get_cart_contents() as $cart_item ) {
$product_id = $cart_item['product_id'];
add_filter('pisol_enq_show_variation_for_simple', '__return_true');
add_action( 'wp_enqueue_scripts', function () {
$js = "
jQuery(document).on('pi_add_to_enquiry_data', function(e, data) {
if (jQuery('.woosb-products').length == 0) return;
jQuery('.woosb-products .woosb-item-product').each(function() {
var name = jQuery(this).data('name');
var val = jQuery('select', this).val();
if(jQuery('select', this).length > 0){
if(val){
@rajeshsingh520
rajeshsingh520 / gist:40bb19a1406dabcadcd18bc02120d990
Created June 13, 2025 08:05
disable mmq request on checkout page
add_action('wp_enqueue_scripts', function() {
if (is_checkout()) {
wp_dequeue_script( 'pisol-mmq-amount' );
}
}, PHP_INT_MAX);
@rajeshsingh520
rajeshsingh520 / gist:87ae0a23bef8111b09ee607d4d9c5f83
Created June 13, 2025 05:55
disable pickup location loading by ajax
add_filter('woocommerce_update_order_review_fragments',function($fragment){
if(is_array($fragment)){
$fragment['dont_reload_pickup_location'] = true;
}
return $fragment;
});
@rajeshsingh520
rajeshsingh520 / gist:3ed14a605daa38392d5b062cd7edef60
Created June 11, 2025 04:44
remove product from cart based on pickup location
class pisol_custom_20250611{
static $instance = null;
public static function get_instance() {
if (self::$instance === null) {
self::$instance = new self();
}
return self::$instance;
}
@rajeshsingh520
rajeshsingh520 / disable-order-limit-byrole.php
Created June 11, 2025 00:50
Disable order limit by user role
add_filter('pisol_disable_order_limit_check', function($disable){
if (is_user_logged_in()) {
$user = wp_get_current_user();
if (in_array('administrator', $user->roles) || in_array('shop_manager', $user->roles)) {
$disable = true;
}
}
return $disable;
});
add_filter('doing_it_wrong_trigger_error', function($doing_it_wrong, $function_name) {
if ('_load_textdomain_just_in_time' === $function_name) {
return false;
}
return $doing_it_wrong;
}, 10, 2);
@rajeshsingh520
rajeshsingh520 / gist:95b8bba7504baa30f2436a2495b003f3
Created May 28, 2025 09:48
Show shipping cost but do not apply it in the final checkout total
add_filter('woocommerce_package_rates', 'override_shipping_cost_to_zero_but_keep_label', PHP_INT_MAX, 2);
function override_shipping_cost_to_zero_but_keep_label($rates, $package) {
foreach ($rates as $rate_id => $rate) {
// Save original cost in the label for display
$original_cost = wc_price($rate->cost);
$rates[$rate_id]->label .= " (Normally $original_cost)";
// Override actual cost to 0
$rates[$rate_id]->cost = 0;