Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class WCFM_Store_Map_Icon_Modifier {
- private $stores_on_vacation = [];
- public function __construct() {
- $this->set_stores_on_vacation();
- add_filter( 'wcfmmp_map_store_icon', array(&$this, 'set_vendor_map_icon'), 50, 3);
- }
- public function set_stores_on_vacation() {
- global $wpdb;
- $vacation_args = array(
- 'role__in' => apply_filters( 'wcfmmp_allwoed_vendor_user_roles', array( 'wcfm_vendor' ) ),
- 'meta_query' => array(
- array(
- array(
- 'key' => 'wcfmmp_profile_settings',
- 'value' => ';s:18:"wcfm_vacation_mode";s:3:"yes";',
- 'compare' => 'LIKE',
- ),
- array(
- 'key' => 'wcfmmp_profile_settings',
- 'value' => ';s:30:"wcfm_disable_vacation_purchase";s:3:"yes";',
- 'compare' => 'LIKE',
- ),
- ),
- ),
- 'fields' => 'ID',
- );
- $on_vacation = get_users( $vacation_args );
- $sql = "select user_id, meta_value from {$wpdb->prefix}usermeta where user_id IN (" . implode( ",", $on_vacation ) . ") AND meta_key = 'wcfmmp_profile_settings'";
- $result = $wpdb->get_results($sql);
- if( !empty( $result ) ) {
- foreach ($result as $value) {
- $settings = maybe_unserialize($value->meta_value);
- if(isset($settings['wcfm_vacation_mode_type']) && 'instant' == $settings['wcfm_vacation_mode_type']) {
- $this->stores_on_vacation[] = $value->user_id;
- continue;
- }
- $wcfm_vacation_start_date = isset($settings['wcfm_vacation_start_date']) ? $settings['wcfm_vacation_start_date'] : '';
- $wcfm_vacation_end_date = isset($settings['wcfm_vacation_end_date']) ? $settings['wcfm_vacation_end_date'] : '';
- if( $wcfm_vacation_start_date && $wcfm_vacation_end_date ) {
- $current_time = strtotime( 'midnight', current_time( 'timestamp' ) );
- $start_time = strtotime( $wcfm_vacation_start_date );
- $end_time = strtotime( $wcfm_vacation_end_date );
- if( ($current_time >= $start_time) && ($current_time <= $end_time) ) {
- $this->stores_on_vacation[] = $value->user_id;
- continue;
- }
- }
- }
- $this->stores_on_vacation = array_unique($this->stores_on_vacation);
- }
- }
- public function set_vendor_map_icon($icon, $store_id, $store_user) {
- global $WCFMmp;
- if( apply_filters( 'wcfm_is_pref_store_hours', true ) && $store_id && wcfm_is_vendor( $store_id ) ) {
- $is_store_close = $WCFMmp->wcfmmp_store_hours->wcfmmp_is_store_close( $store_id );
- if($is_store_close || in_array($store_id, $this->stores_on_vacation)) {
- return 'https://maps.google.com/mapfiles/marker.png';
- } else {
- return 'https://maps.google.com/mapfiles/marker_green.png';
- }
- }
- return $icon;
- }
- }
- add_filter('wcfmmp_map_store_info', function($info) {
- new WCFM_Store_Map_Icon_Modifier();
- return $info;
- });
Advertisement
Comments
-
- https://biicorp.com/vendors-list/
- i have to pass the code the my website and change the close time, it just show only the open, not show for close, so how to fix it, thank you
Add Comment
Please, Sign In to add comment
Advertisement