Created
January 6, 2025 09:54
-
-
Save rajeshsingh520/a8cb00a0596d5d7bf0c6c73c0e26e3a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class disable_date_time_for_shipping_method{ | |
static $instance = null; | |
public $shipping_method = 'free_shipping:55';//'flat_rate:2160'; | |
static function get_instance(){ | |
if(is_null(self::$instance)){ | |
self::$instance = new self(); | |
} | |
return self::$instance; | |
} | |
function __construct(){ | |
add_filter('pisol_pldt_settings_filter', array($this, 'hideDateTimeField'), PHP_INT_MAX); | |
add_filter('pisol_dtt_setting_filter_pi_datetime', [$this, 'disableDateTimeField'], PHP_INT_MAX); | |
} | |
function hideDateTimeField($settings){ | |
if($this->disable_date_time_method_selected()){ | |
$settings['disable_date_time_field'] = 1; | |
} | |
return $settings; | |
} | |
function disable_date_time_method_selected(){ | |
if(isset(WC()->session) && is_object(WC()->session)){ | |
$chosen_shipping_methods = WC()->session->get('chosen_shipping_methods'); | |
if(is_array($chosen_shipping_methods)){ | |
foreach($chosen_shipping_methods as $shipping_method){ | |
if($shipping_method == $this->shipping_method){ | |
return true; | |
} | |
} | |
} | |
} | |
return false; | |
} | |
function disableDateTimeField($enabled){ | |
if($this->disable_date_time_method_selected()){ | |
return 'disable-both'; | |
} | |
return $enabled; | |
} | |
} | |
disable_date_time_for_shipping_method::get_instance(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment