# Remote Area Shipping Surcharge

> Adds a surcharge to the order when the shipping postcode is in a remote area you list, such as islands or highland regions that carriers charge extra for.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, shipping, fees, postcodes
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-remote-area-surcharge/

## Code

```php
$wpide_remote = array(
    'prefixes' => array( 'HS', 'ZE', 'KW15', 'PA41' ), // Postcode prefixes.
    'amount'   => 9.95,                                // Surcharge.
    'label'    => 'Remote area surcharge',
    'taxable'  => true,
);

add_action( 'woocommerce_cart_calculate_fees', function ( $cart ) use ( $wpide_remote ) {
    if ( ( is_admin() && ! wp_doing_ajax() ) || ! $cart->needs_shipping() ) {
        return;
    }

    $postcode = strtoupper( str_replace( ' ', '', (string) WC()->customer->get_shipping_postcode() ) );

    if ( '' === $postcode ) {
        return;
    }

    foreach ( $wpide_remote['prefixes'] as $prefix ) {
        if ( 0 === strpos( $postcode, strtoupper( $prefix ) ) ) {
            $cart->add_fee( $wpide_remote['label'], $wpide_remote['amount'], $wpide_remote['taxable'] );
            return;
        }
    }
} );
```

## Notes

Postcodes match by prefix, so 'HS' covers HS1 to HS9; set 'taxable' to false if the fee should not be taxed.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Remote Area Shipping Surcharge" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
