- 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
Fixes:
1. SearchableSelect now supports onSearch prop for API-based search
- Added onSearch and isSearching props
- shouldFilter disabled when onSearch provided
2. DynamicCheckoutField connects handleApiSearch to SearchableSelect
3. RAJAONGKIR_INTEGRATION.md adds both billing and shipping destination_id
This enables the destination search field to actually call the API
when user types, instead of just filtering local (empty) options.
Root causes fixed:
1. API method: search_destination_api() not search_destination()
2. Field filter: removed country check that failed before user selection
3. Field now always added if store sells to Indonesia
The woocommerce_checkout_fields filter now:
- Checks if Rajaongkir is active
- Checks if Indonesia is in allowed countries
- Always adds field (frontend will show/hide based on country)
Based on deep analysis of Rajaongkir plugin:
- Destinations searched via RajaOngkir API (no local DB table)
- Uses Cekongkir_API::search_destination() for search
- Session 'selected_destination_id' required for rates
- Added SPA-aware checkout field injection
Code snippet includes:
1. REST endpoint /woonoow/v1/rajaongkir/destinations
2. Checkout field filter with REST context detection
3. Session bridge via woonoow/shipping/before_calculate
Backend (CheckoutController):
- Enhanced get_fields() API with custom_attributes, search_endpoint,
search_param, min_chars, input_class, default
- Supports new 'searchable_select' field type for API-backed search
Customer SPA:
- Created DynamicCheckoutField component for all field types
- Checkout fetches fields from /checkout/fields API
- Renders custom fields from PHP filters (billing + shipping)
- searchable_select type with live API search
- Custom field data included in checkout submission
This enables:
- Checkout Field Editor Pro compatibility
- Rajaongkir destination_id via simple code snippet
- Any plugin using woocommerce_checkout_fields filter
Updated RAJAONGKIR_INTEGRATION.md with code snippet approach.
Admin SPA:
- Changed billing/shipping state from Select to SearchableSelect
Customer SPA:
- Added cmdk package for command palette
- Created popover, command, and searchable-select UI components
- Added searchable country and state fields to checkout
- Fetches countries/states from /countries API
- Auto-clears state when country changes
Backend:
- Added generic woonoow/shipping/before_calculate hook
- Removed hardcoded Rajaongkir session handling
Documentation:
- Updated RAJAONGKIR_INTEGRATION.md with:
- Complete searchable destination selector plugin code
- JavaScript implementation
- React component version
- REST API endpoint for destination search