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
This commit is contained in:
Dwindi Ramadhana
2026-01-08 11:00:55 +07:00
parent 83836298ec
commit 786e01c8f6
3 changed files with 232 additions and 21 deletions

View File

@@ -1485,16 +1485,18 @@ class OrdersController {
WC()->customer->set_billing_postcode( $postcode );
WC()->customer->set_billing_city( $city );
// Support for Rajaongkir plugin - set destination in session
// Rajaongkir uses session-based destination instead of standard address fields
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'] ?? $city );
} else {
// Clear Rajaongkir session data for non-ID countries
WC()->session->__unset( 'selected_destination_id' );
WC()->session->__unset( 'selected_destination_label' );
}
/**
* Allow shipping addons to prepare session/data before shipping calculation.
*
* This hook allows third-party shipping plugins (like Rajaongkir, Biteship, etc.)
* to set any session variables or prepare data they need before WooCommerce
* calculates shipping rates.
*
* @since 1.0.0
* @param array $shipping The shipping address data from frontend (country, state, city, postcode, address_1, etc.)
* @param array $items The cart items being shipped
*/
do_action( 'woonoow/shipping/before_calculate', $shipping, $items ?? [] );
}
// Calculate shipping