# Flag Orders Whose Billing and Shipping Countries Differ

> Adds a private order note, and optionally holds the order, when the billing and shipping countries do not match, a common sign of card fraud.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, orders, fraud, notes
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-flag-country-mismatch/

## Code

```php
$wpide_mismatch_hold = false; // Also set the order to On hold.

$wpide_check_mismatch = function ( $order ) use ( $wpide_mismatch_hold ) {
    if ( ! $order instanceof WC_Order || ! $order->has_shipping_address() ) {
        return;
    }

    $billing  = $order->get_billing_country();
    $shipping = $order->get_shipping_country();

    if ( $billing && $shipping && $billing !== $shipping ) {
        $order->add_order_note( sprintf( 'Check: billing country (%1$s) and shipping country (%2$s) differ.', $billing, $shipping ) );

        if ( $wpide_mismatch_hold && $order->has_status( array( 'processing', 'pending' ) ) ) {
            $order->update_status( 'on-hold', 'Held because the countries differ.' );
        }
    }
};

add_action( 'woocommerce_checkout_order_created', $wpide_check_mismatch );
add_action( 'woocommerce_store_api_checkout_order_processed', $wpide_check_mismatch );
```

## Notes

Works with the classic and block checkouts; set $wpide_mismatch_hold to true to also put these orders on hold.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Flag Orders Whose Billing and Shipping Countries Differ" 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/
