
In a recent Business Bloomer Club thread, a member raised a question about displaying rounded prices for non-European customers. Although prices on the site were set to include VAT, users outside of Europe were seeing unrounded, non-taxed prices (e.g., €1143.75 displayed as €1144).
The goal was to adjust both the display and actual prices, so non-European customers would see rounded amounts in all relevant areas, such as product pages, cart, and checkout.
Here’s a guide on how to implement this feature by overriding WooCommerce product prices based on the customer’s location.
Solution: Using PHP to Override Product Prices
Step 1: Set Up Country Detection
WooCommerce’s Geolocation feature can help identify the user’s country. To make this work, you’ll need to detect non-EU customers and adjust prices accordingly. The WooCommerce Geolocation guide provides details on how to implement this.
Step 2: Override Prices with Rounded Values
To change prices for non-EU customers, you’ll need a PHP function that applies custom price logic. Here’s how to get started:
- Use the
woocommerce_product_get_price
andwoocommerce_product_get_regular_price
filters to override displayed prices. - Set conditional logic to check if the user is outside the EU and then apply a PHP
round()
function to the price.
For example:
add_filter( 'woocommerce_product_get_price', 'custom_round_price_for_non_eu', 10, 2 );
add_filter( 'woocommerce_product_get_regular_price', 'custom_round_price_for_non_eu', 10, 2 );
function custom_round_price_for_non_eu( $price, $product ) {
if ( !is_eu_customer() ) { // Replace with actual EU check
$price = round( $price );
}
return $price;
}
Step 3: Set Up Cart and Checkout Adjustments
For consistent pricing throughout checkout, apply the same price logic within WooCommerce’s cart and checkout filters. The WooCommerce price override guide details how to implement these changes programmatically.
Final Thoughts
This approach ensures that non-EU customers see clean, rounded prices without VAT across your WooCommerce store, enhancing clarity and uniformity in pricing display.