Commit Graph

9 Commits

Author SHA1 Message Date
Dwindi Ramadhana
533cf5e7d2 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
2026-01-08 14:50:08 +07:00
Dwindi Ramadhana
f518d7e589 feat(checkout): fix searchable select API search and add billing destination
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.
2026-01-08 14:47:54 +07:00
Dwindi Ramadhana
f6b778c7fc fix(rajaongkir): correct API method name and remove premature country check
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)
2026-01-08 14:38:52 +07:00
Dwindi Ramadhana
906ad38a36 docs(rajaongkir): update integration guide with correct code snippet
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
2026-01-08 14:17:58 +07:00
Dwindi Ramadhana
6694d9e0c4 feat(checkout): dynamic checkout fields with PHP filter support
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.
2026-01-08 11:48:53 +07:00
Dwindi Ramadhana
2939ebfe6b feat(checkout): searchable address fields and Rajaongkir integration
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
2026-01-08 11:19:37 +07:00
Dwindi Ramadhana
786e01c8f6 feat(shipping): searchable state fields and addon hook
1. Admin OrderForm: Changed billing & shipping state from Select to
   SearchableSelect for better UX (consistent with country field)

2. OrdersController: Replaced Rajaongkir-specific hardcoded session
   handling with generic filter hook:
   do_action('woonoow/shipping/before_calculate', $shipping, $items)

3. Added RAJAONGKIR_INTEGRATION.md with:
   - Hook documentation
   - Code snippet to bridge Rajaongkir with WooNooW
   - Frontend integration examples
   - Troubleshooting guide
2026-01-08 11:00:55 +07:00
Dwindi Ramadhana
07020bc0dd feat: Implement centralized module management system
- Add ModuleRegistry for managing built-in modules (newsletter, wishlist, affiliate, subscription, licensing)
- Add ModulesController REST API for module enable/disable
- Create Modules settings page with category grouping and toggle controls
- Integrate module checks across admin-spa and customer-spa
- Add useModules hook for both SPAs to check module status
- Hide newsletter from footer builder when module disabled
- Hide wishlist features when module disabled (product cards, account menu, wishlist page)
- Protect wishlist API endpoints with module checks
- Auto-update navigation tree when modules toggled
- Clean up obsolete documentation files
- Add comprehensive documentation:
  - MODULE_SYSTEM_IMPLEMENTATION.md
  - MODULE_INTEGRATION_SUMMARY.md
  - ADDON_MODULE_INTEGRATION.md (proposal)
  - ADDON_MODULE_DESIGN_DECISIONS.md (design doc)
  - FEATURE_ROADMAP.md
  - SHIPPING_INTEGRATION.md

Module system provides:
- Centralized enable/disable for all features
- Automatic navigation updates
- Frontend/backend integration
- Foundation for addon-module unification
2025-12-26 19:19:49 +07:00
dwindown
03ef9e3f24 docs: Document Rajaongkir integration issue and add session support
## Discovery 

Rajaongkir plugin uses a completely different approach:
- Removes standard WooCommerce city/state fields
- Adds custom destination dropdown with Select2 search
- Stores destination in WooCommerce session (not address fields)
- Reads from session during shipping calculation

## Root Cause of Issues:

### 1. Same rates for different provinces
- OrderForm sends: city="Bandung", state="Jawa Barat"
- Rajaongkir ignores these fields
- Rajaongkir reads: WC()->session->get("selected_destination_id")
- Session empty → Uses cached/default rates

### 2. No Rajaongkir API hits
- No destination_id in session
- Rajaongkir can't calculate without destination
- Returns empty or cached rates

## Backend Fix ( DONE):

Added Rajaongkir session support in calculate_shipping:
```php
// Support for Rajaongkir plugin
if ( $country === 'ID' && ! empty( $shipping['destination_id'] ) ) {
    WC()->session->set( 'selected_destination_id', $shipping['destination_id'] );
    WC()->session->set( 'selected_destination_label', $shipping['destination_label'] );
}
```

## Frontend Fix (TODO):

Need to add Rajaongkir destination field:
1. Add destination search component (Select2/Combobox)
2. Search Rajaongkir API for locations
3. Pass destination_id to backend
4. Backend sets session before calculate_shipping()

## Documentation:

Created RAJAONGKIR_INTEGRATION.md with:
- How Rajaongkir works
- Why our implementation fails
- Complete solution steps
- Testing checklist

## Next Steps:

1. Add Rajaongkir search endpoint to OrdersController
2. Create destination search component in OrderForm
3. Pass destination_id in shipping data
4. Test with real Rajaongkir API
2025-11-10 18:56:41 +07:00