fix: Add region search filter + pre-select on edit + create plan doc
## ✅ Issue #1: TAX_NOTIFICATIONS_PLAN.md Created - Complete implementation plan for Tax & Notifications - 80/20 rule: Core features vs Advanced (WooCommerce) - API endpoints defined - Implementation phases prioritized ## ✅ Issue #2: Region Search Filter - Added search input above region list - Real-time filtering as you type - Shows "No regions found" when no matches - Clears search on dialog close/cancel - Makes finding countries/states MUCH faster! ## ✅ Issue #3: Pre-select Regions on Edit - Backend now returns raw `locations` array - Frontend uses `defaultChecked` with location matching - Existing regions auto-selected when editing zone - Works correctly for countries, states, and continents ## UX Improvements: - Search placeholder: "Search regions..." - Filter is case-insensitive - Empty state when no results - Clean state management (clear on close) Now zone editing is smooth and fast!
This commit is contained in:
@@ -229,8 +229,16 @@ class ShippingController extends WP_REST_Controller {
|
||||
// Get zone locations (regions)
|
||||
$locations = $zone->get_zone_locations();
|
||||
$regions = array();
|
||||
$raw_locations = array();
|
||||
|
||||
foreach ( $locations as $location ) {
|
||||
// Store raw location data for editing
|
||||
$raw_locations[] = array(
|
||||
'code' => $location->code,
|
||||
'type' => $location->type,
|
||||
);
|
||||
|
||||
// Format for display
|
||||
if ( $location->type === 'country' ) {
|
||||
$countries = WC()->countries->get_countries();
|
||||
$regions[] = $countries[ $location->code ] ?? $location->code;
|
||||
@@ -280,11 +288,12 @@ class ShippingController extends WP_REST_Controller {
|
||||
}
|
||||
|
||||
$zones_data[] = array(
|
||||
'id' => $zone_data['id'],
|
||||
'name' => $zone->get_zone_name(),
|
||||
'order' => $zone->get_zone_order(),
|
||||
'regions' => ! empty( $regions ) ? implode( ', ', $regions ) : __( 'No regions', 'woonoow' ),
|
||||
'rates' => $rates,
|
||||
'id' => $zone_data['id'],
|
||||
'name' => $zone->get_zone_name(),
|
||||
'order' => $zone->get_zone_order(),
|
||||
'regions' => ! empty( $regions ) ? implode( ', ', $regions ) : __( 'No regions', 'woonoow' ),
|
||||
'locations' => $raw_locations,
|
||||
'rates' => $rates,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user