Skip to content

Instantly share code, notes, and snippets.

@rajeshsingh520
Created July 9, 2025 03:57
Show Gist options
  • Save rajeshsingh520/957a80feab503e9931a8dc0579950f44 to your computer and use it in GitHub Desktop.
Save rajeshsingh520/957a80feab503e9931a8dc0579950f44 to your computer and use it in GitHub Desktop.
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) ) {
return $data;
}
// Admin-defined static configuration
$start_date = '2025-07-25';
$end_date = '2025-08-10';
$start_range_min = 10;
$start_range_max = 15;
$today = current_time('Y-m-d');
$today_ts = strtotime( current_time('Y-m-d') );
$start_date_ts = strtotime( $start_date );
$end_date_ts = strtotime( $end_date );
// Apply countdown logic only between start_date and end_date
if ( $today_ts >= $start_date_ts && $today_ts <= $end_date_ts ) {
$days_passed = (strtotime($today) - strtotime($start_date)) / DAY_IN_SECONDS;
$min_days = max(1, $start_range_min - $days_passed);
$max_days = max($min_days, $start_range_max - $days_passed); // max must be >= min
$data['min_preparation_days'] = (int) $min_days;
$data['max_preparation_days'] = (int) $max_days;
}
return $data;
}, 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment