PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.29
Booktics – Appointment Booking Calendar for Service Businesses v1.0.29
1.0.29 1.0.28 1.0.27 1.0.26 1.0.25 1.0.24 1.0.23 1.0.22 1.0.21 1.0.20 1.0.19 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.2 1.0.3 All 31 releases
← All changes | core/service/controllers/service-controller.php +20 -8 1.0.17 → 1.0.29 View file →
@@ -217,8 +217,28 @@
217 217 }
218 218
219 219 $args = apply_filters( 'booktics_service_args', $args, $request );
220 220
221 + // Get service IDs for category BEFORE pagination to ensure correct total count
222 + $service_ids_for_category = null;
223 + if ( ! empty( $request['category_id'] ) ) {
224 + $service_ids_for_category = get_term_meta( absint( $request['category_id'] ), 'booktics_category_services', true );
225 +
226 + // If category filter is applied, add post__in to args to filter BEFORE pagination
227 + if ( ! empty( $service_ids_for_category ) && is_array( $service_ids_for_category ) ) {
228 + $args['post__in'] = $service_ids_for_category;
229 + } elseif ( ! empty( $service_ids_for_category ) ) {
230 + // If category has no services, return early
231 + return $this->response( array(
232 + 'items' => array(),
233 + 'total' => 0,
234 + 'per_page' => $per_page,
235 + 'current_page' => $paged,
236 + 'last_page' => 0,
237 + ) );
238 + }
239 + }
240 +
221 241 $data = Service_Model::paginate( $per_page, $paged, $args );
222 242
223 243 if ( ! $data ) {
224 244 return $this->error( __( 'No service found', 'booktics' ), 404 );
@@ -223,20 +243,12 @@
223 243 if ( ! $data ) {
224 244 return $this->error( __( 'No service found', 'booktics' ), 404 );
225 245 }
226 246
227 - if ( ! empty( $request['category_id'] ) ) {
228 - $service_ids_for_category = get_term_meta( absint( $request['category_id'] ), 'booktics_category_services', true );
229 - }
230 -
231 247 if ( ! empty( $data['items'] ) ) {
232 248 $enhanced_items = array();
233 249 foreach ( $data['items'] as $service ) {
234 250 $service_array = $service->to_array();
235 -
236 - if ( isset( $service_ids_for_category ) && ! in_array( $service_array['id'], $service_ids_for_category ) ) {
237 - continue;
238 - }
239 251
240 252 if ( ! empty( $service_array['team_member'] ) ) {
241 253 $team_member_ids = is_array( $service->team_member ) ? array_unique( $service->team_member ) : array( $service->team_member );
242 254 $service->team_member = $team_member_ids;