# Simplify the Cart Shipping Calculator

> Removes the city and postcode or state boxes from the cart's shipping calculator when your rates only depend on the country.

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

## Code

```php
$wpide_calc_keep = array(
    'state'    => false, // Keep the state/county field.
    'city'     => false, // Keep the city field.
    'postcode' => false, // Keep the postcode field.
);

add_filter( 'woocommerce_shipping_calculator_enable_state', function () use ( $wpide_calc_keep ) {
    return $wpide_calc_keep['state'];
} );
add_filter( 'woocommerce_shipping_calculator_enable_city', function () use ( $wpide_calc_keep ) {
    return $wpide_calc_keep['city'];
} );
add_filter( 'woocommerce_shipping_calculator_enable_postcode', function () use ( $wpide_calc_keep ) {
    return $wpide_calc_keep['postcode'];
} );
```

## Notes

Set any of the three values to true to keep that field.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Simplify the Cart Shipping Calculator" 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/
