Example #1
0
 static function user_booked($post_id = false)
 {
     if (!$post_id) {
         $post_id = get_the_ID();
     }
     if (!is_user_logged_in()) {
         return false;
     }
     $post_type = get_post_type($post_id);
     $user_id = get_current_user_id();
     $allow_review = true;
     switch ($post_type) {
         case "st_hotel":
             //Search Order By Customer ID
             $order = new STOrder();
             $count = $order->check_user_booked($user_id, $post_id, $post_type);
             if ($count < 1) {
                 $allow_review = FALSE;
             }
             break;
         case "st_rental":
             //Search Order By Customer ID
             $order = new STOrder();
             $count = $order->check_user_booked($user_id, $post_id, $post_type);
             if ($count < 1) {
                 $allow_review = FALSE;
             }
             break;
         case "st_cars":
             //$allow_review= True;
             $order = new STOrder();
             $count = $order->check_user_booked($user_id, $post_id, $post_type);
             if ($count < 1) {
                 $allow_review = FALSE;
             }
             break;
         case "st_tours":
         case "st_holidays":
         case "st_activity":
             //Search Order By Customer ID
             $order = new STOrder();
             $count = $order->check_user_booked($user_id, $post_id, $post_type);
             if ($count < 1) {
                 $allow_review = FALSE;
             }
             break;
             break;
         default:
             $allow_review = FALSE;
             break;
     }
     return $allow_review;
 }