fix(rajaongkir): fix relative endpoint path and increase min_chars to 3

- search_endpoint changed from '/woonoow/v1/rajaongkir/destinations'
  to '/rajaongkir/destinations' (relative to API base)
- min_chars increased from 2 to 3 to reduce early API hits
This commit is contained in:
Dwindi Ramadhana
2026-01-08 14:50:08 +07:00
parent f518d7e589
commit 533cf5e7d2

View File

@@ -50,7 +50,7 @@ add_action('rest_api_init', function() {
function woonoow_rajaongkir_search_destinations($request) { function woonoow_rajaongkir_search_destinations($request) {
$search = sanitize_text_field($request->get_param('search') ?? ''); $search = sanitize_text_field($request->get_param('search') ?? '');
if (strlen($search) < 2) { if (strlen($search) < 3) {
return []; return [];
} }
@@ -112,9 +112,10 @@ add_filter('woocommerce_checkout_fields', function($fields) {
'class' => ['form-row-wide'], 'class' => ['form-row-wide'],
'placeholder' => __('Search destination...', 'woonoow'), 'placeholder' => __('Search destination...', 'woonoow'),
// WooNooW-specific: API endpoint configuration // WooNooW-specific: API endpoint configuration
'search_endpoint' => '/woonoow/v1/rajaongkir/destinations', // NOTE: Path is relative to /wp-json/woonoow/v1
'search_endpoint' => '/rajaongkir/destinations',
'search_param' => 'search', 'search_param' => 'search',
'min_chars' => 2, 'min_chars' => 3,
// Custom attribute to indicate this is for Indonesia only // Custom attribute to indicate this is for Indonesia only
'custom_attributes' => [ 'custom_attributes' => [
'data-show-for-country' => 'ID', 'data-show-for-country' => 'ID',