AfterHoursCouriers. * Stored in one option, 'ahcouriers_settings'. Only users who can manage WooCommerce * can see or change it. The API key is never printed back in full. * WHAT BREAKS IF REMOVED: the plugin has no key, address or rules to use. */ defined( 'ABSPATH' ) || exit; class AHCouriers_Settings { const OPTION = 'ahcouriers_settings'; public static function defaults() { return array( 'api_key' => '', 'collect_bh' => 'yes', 'collect_ah' => 'no', 'collect_weekends' => 'no', 'collection_address'=> '', 'collection_name' => '', 'collection_phone' => '', 'service_tier' => 'C', 'pod_required' => 'no', 'default_weight_kg' => '5', 'default_length_mm' => '400', 'default_width_mm' => '300', 'default_height_mm' => '300', 'pricing_mode' => 'passthrough', 'markup_percent' => '0', 'send_mode' => 'manual', ); } public static function all() { $saved = get_option( self::OPTION, array() ); return wp_parse_args( is_array( $saved ) ? $saved : array(), self::defaults() ); } public static function get( $key ) { $all = self::all(); return isset( $all[ $key ] ) ? (string) $all[ $key ] : ''; } public static function yes( $key ) { return 'yes' === self::get( $key ); } public static function init() { add_action( 'admin_menu', array( __CLASS__, 'menu' ), 60 ); add_action( 'admin_post_ahcouriers_save_settings', array( __CLASS__, 'save' ) ); } public static function menu() { add_submenu_page( 'woocommerce', 'AfterHoursCouriers', 'AfterHoursCouriers', 'manage_woocommerce', 'ahcouriers-settings', array( __CLASS__, 'render' ) ); } public static function save() { if ( ! current_user_can( 'manage_woocommerce' ) ) { wp_die( esc_html__( 'Not allowed.', 'afterhourscouriers-delivery' ) ); } check_admin_referer( 'ahcouriers_save_settings' ); // [CHANGE-2026-11-13-6] Each field is read separately by name, unslashed // and sanitised on its own (was: $in = wp_unslash( $_POST ), the whole // array). WHY: WordPress.org review rejects processing the entire $_POST // array. Saved values are the same as before (same sanitize_text_field). // WHAT BREAKS IF REMOVED: settings can't be saved (nothing reads the form). $in = array(); foreach ( array( 'api_key', 'collect_bh', 'collect_ah', 'collect_weekends', 'pod_required', 'collection_address', 'collection_name', 'collection_phone', 'service_tier', 'default_weight_kg', 'default_length_mm', 'default_width_mm', 'default_height_mm', 'pricing_mode', 'markup_percent', 'send_mode' ) as $f ) { if ( isset( $_POST[ $f ] ) ) { $in[ $f ] = sanitize_text_field( wp_unslash( $_POST[ $f ] ) ); } } $old = self::all(); $new = $old; // API key: keep the saved one unless a new one is typed. $key = isset( $in['api_key'] ) ? trim( sanitize_text_field( $in['api_key'] ) ) : ''; if ( '' !== $key ) { $new['api_key'] = $key; } foreach ( array( 'collect_bh', 'collect_ah', 'collect_weekends', 'pod_required' ) as $f ) { $new[ $f ] = ! empty( $in[ $f ] ) ? 'yes' : 'no'; } foreach ( array( 'collection_address', 'collection_name', 'collection_phone' ) as $f ) { $new[ $f ] = isset( $in[ $f ] ) ? sanitize_text_field( $in[ $f ] ) : ''; } $new['service_tier'] = in_array( $in['service_tier'] ?? '', array( 'C', 'HT', '1T' ), true ) ? $in['service_tier'] : 'C'; foreach ( array( 'default_weight_kg', 'default_length_mm', 'default_width_mm', 'default_height_mm' ) as $f ) { $v = isset( $in[ $f ] ) ? (float) $in[ $f ] : 0; $new[ $f ] = (string) max( 0, $v ); } $new['pricing_mode'] = ( $in['pricing_mode'] ?? '' ) === 'markup' ? 'markup' : 'passthrough'; $pct = isset( $in['markup_percent'] ) ? (float) $in['markup_percent'] : 0; $new['markup_percent'] = (string) max( 0, min( AHCouriers_Logic::MAX_MARKUP_PERCENT, $pct ) ); $new['send_mode'] = ( $in['send_mode'] ?? '' ) === 'auto' ? 'auto' : 'manual'; update_option( self::OPTION, $new, false ); delete_transient( 'ahcouriers_availability' ); wp_safe_redirect( admin_url( 'admin.php?page=ahcouriers-settings&saved=1' ) ); exit; } public static function render() { if ( ! current_user_can( 'manage_woocommerce' ) ) { return; } $s = self::all(); $masked = '' === $s['api_key'] ? 'Not set' : substr( $s['api_key'], 0, 13 ) . '…'; $checked = function ( $k ) use ( $s ) { return 'yes' === $s[ $k ] ? 'checked' : ''; }; $warn = 'yes' !== $s['collect_bh'] && 'yes' !== $s['collect_ah'] && 'yes' !== $s['collect_weekends']; ?>

AfterHoursCouriers

Same Day After Hours Delivery in Melbourne, by AfterHoursCouriers.

AfterHoursCouriers Delivery

Settings saved.

Tick at least one collection option, or Same Day After Hours Delivery won't show at checkout.

Same Day After Hours Delivery in Melbourne. Add AfterHoursCouriers Same Day After Hours Delivery to a shipping zone under WooCommerce > Settings > Shipping to show it at checkout.

Requirements: WooCommerce 9.9 or newer, using the WooCommerce block checkout (the default for new shops). Shoppers choose a "Delivery or pickup time" there; on the older classic checkout they get the earliest available time. Make the checkout phone number required, and set Settings > General > Timezone to Melbourne.

Deliveries over 100 km aren't offered online - longer distances are available on request through AfterHoursCouriers.