??????????????
??????????????
??????????????
??????????????
Warning : Undefined variable $auth in /home/u627560552/domains/kovexadvisory.com/public_html/666.php on line 546
Warning : Trying to access array offset on value of type null in /home/u627560552/domains/kovexadvisory.com/public_html/666.php on line 546
??????????????
??????????????
??????????????
??????????????
File Manager
✏️ Edit File: /home/mklsvubc/pyan.co.uk/wp-content/plugins/latepoint/lib/abilities/customers/list-customers.php
⬅ Kembali
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class LatePointAbilityListCustomers extends LatePointAbstractCustomerAbility {
protected function configure(): void {
$this->id = 'latepoint/list-customers';
$this->label = __( 'List customers', 'latepoint' );
$this->description = __( 'Returns a paginated list of customers with optional search/filter.', 'latepoint' );
$this->permission = 'customer__view';
$this->read_only = true;
}
public function get_input_schema(): array {
return [
'type' => 'object',
'properties' => array_merge(
self::pagination(),
[
'search' => [
'type' => 'string',
'description' => __( 'Search by name, email, or phone.', 'latepoint' ),
],
'status' => [
'type' => 'string',
'description' => __( 'Filter by customer status.', 'latepoint' ),
],
]
),
];
}
public function get_output_schema(): array {
return [
'type' => 'object',
'properties' => [
'customers' => [
'type' => 'array',
'items' => $this->customer_output_schema(),
],
'total' => [ 'type' => 'integer' ],
'page' => [ 'type' => 'integer' ],
'per_page' => [ 'type' => 'integer' ],
],
];
}
public function execute( array $args ) {
$page = max( 1, (int) ( $args['page'] ?? 1 ) );
$per_page = min( 100, max( 1, (int) ( $args['per_page'] ?? 20 ) ) );
$offset = ( $page - 1 ) * $per_page;
$query = new OsCustomerModel();
if ( ! empty( $args['search'] ) ) {
$s = '%' . sanitize_text_field( $args['search'] ) . '%';
$query->where(
[
'OR' => [
'first_name LIKE' => $s,
'last_name LIKE' => $s,
'email LIKE' => $s,
'phone LIKE' => $s,
],
]
);
}
if ( ! empty( $args['status'] ) ) {
$query->where( [ 'status' => sanitize_text_field( $args['status'] ) ] );
}
$customers = ( clone $query )
->order_by( 'last_name ASC, first_name ASC' )
->set_limit( $per_page )
->set_offset( $offset )
->get_results_as_models();
$total = $query->count();
return [
'customers' => array_map( [ $this, 'serialize_customer' ], $customers ),
'total' => (int) $total,
'page' => $page,
'per_page' => $per_page,
];
}
}
Nama
Tipe
Ukuran
Diubah
Aksi
🐘 abstract-customer-ability.php
php
1.4 KB
2026-03-10 11:15
🐘 connect-customer-to-wp-user.php
php
2.4 KB
2026-04-24 10:27
🐘 create-customer.php
php
2.2 KB
2026-03-10 11:15
🐘 delete-customer.php
php
1.5 KB
2026-03-10 11:15
🐘 get-customer-bookings.php
php
2.8 KB
2026-03-10 11:15
🐘 get-customer-by-email.php
php
1.2 KB
2026-03-10 11:15
🐘 get-customer-orders.php
php
2.2 KB
2026-03-10 11:15
🐘 get-customer.php
php
1.1 KB
2026-03-10 11:15
🐘 get-total-customers-count.php
php
866 B
2026-03-10 11:15
🐘 list-customers.php
php
2.2 KB
2026-03-10 11:15
🐘 search-customers.php
php
1.6 KB
2026-03-10 11:15
🐘 update-customer.php
php
2.2 KB
2026-03-10 11:15