Advertisement
palsushobhan

shop_open_close_marker_icons_on_map

Aug 6th, 2024 (edited)
149
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.35 KB | None | 0 0
  1. class WCFM_Store_Map_Icon_Modifier {
  2.     private $stores_on_vacation = [];
  3.     public function __construct() {
  4.         $this->set_stores_on_vacation();
  5.         add_filter( 'wcfmmp_map_store_icon', array(&$this, 'set_vendor_map_icon'), 50, 3);
  6.     }
  7.     public function set_stores_on_vacation() {
  8.         global $wpdb;
  9.         $vacation_args = array(
  10.             'role__in'   => apply_filters( 'wcfmmp_allwoed_vendor_user_roles', array( 'wcfm_vendor' ) ),
  11.             'meta_query' => array(
  12.                 array(
  13.                     array(
  14.                         'key'     => 'wcfmmp_profile_settings',
  15.                         'value'   => ';s:18:"wcfm_vacation_mode";s:3:"yes";',
  16.                         'compare' => 'LIKE',
  17.                     ),
  18.                     array(
  19.                         'key'     => 'wcfmmp_profile_settings',
  20.                         'value'   => ';s:30:"wcfm_disable_vacation_purchase";s:3:"yes";',
  21.                         'compare' => 'LIKE',
  22.                     ),
  23.                 ),
  24.             ),
  25.             'fields' => 'ID',
  26.         );
  27.         $on_vacation = get_users( $vacation_args );
  28.         $sql = "select user_id, meta_value from {$wpdb->prefix}usermeta where user_id IN (" . implode( ",", $on_vacation ) . ") AND meta_key = 'wcfmmp_profile_settings'";
  29.         $result = $wpdb->get_results($sql);
  30.         if( !empty( $result ) ) {
  31.             foreach ($result as $value) {
  32.                 $settings = maybe_unserialize($value->meta_value);
  33.                 if(isset($settings['wcfm_vacation_mode_type']) && 'instant' == $settings['wcfm_vacation_mode_type']) {
  34.                     $this->stores_on_vacation[] = $value->user_id;
  35.                     continue;
  36.                 }
  37.                 $wcfm_vacation_start_date = isset($settings['wcfm_vacation_start_date']) ? $settings['wcfm_vacation_start_date'] : '';
  38.                 $wcfm_vacation_end_date = isset($settings['wcfm_vacation_end_date']) ? $settings['wcfm_vacation_end_date'] : '';
  39.                 if( $wcfm_vacation_start_date && $wcfm_vacation_end_date ) {
  40.                     $current_time = strtotime( 'midnight', current_time( 'timestamp' ) );
  41.                     $start_time = strtotime( $wcfm_vacation_start_date );
  42.                     $end_time = strtotime( $wcfm_vacation_end_date );
  43.                     if( ($current_time >= $start_time) && ($current_time <= $end_time) ) {
  44.                         $this->stores_on_vacation[] = $value->user_id;
  45.                         continue;
  46.                     }
  47.                 }
  48.             }
  49.             $this->stores_on_vacation = array_unique($this->stores_on_vacation);
  50.         }
  51.     }
  52.     public function set_vendor_map_icon($icon, $store_id, $store_user) {
  53.         global $WCFMmp;
  54.         if( apply_filters( 'wcfm_is_pref_store_hours', true ) && $store_id && wcfm_is_vendor( $store_id ) ) {
  55.             $is_store_close = $WCFMmp->wcfmmp_store_hours->wcfmmp_is_store_close( $store_id );
  56.             if($is_store_close || in_array($store_id, $this->stores_on_vacation)) {
  57.                 return 'https://maps.google.com/mapfiles/marker.png';
  58.             } else {
  59.                 return 'https://maps.google.com/mapfiles/marker_green.png';
  60.             }
  61.         }
  62.         return $icon;
  63.     }
  64. }
  65.  
  66. add_filter('wcfmmp_map_store_info', function($info) {
  67.     new WCFM_Store_Map_Icon_Modifier();
  68.     return $info;
  69. });
Advertisement
Comments
  • flyb1663
    155 days
    # text 0.17 KB | 0 0
    1. https://biicorp.com/vendors-list/
    2. 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