Show tax-inclusive local prices in comparison

Google Merchant Center prices are always tax-inclusive, so now
the local WooCommerce price is also displayed with tax included
using wc_get_price_including_tax() for a fair comparison.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-23 17:53:24 +01:00
parent 6209229e06
commit 848a29dfa7

View File

@@ -883,11 +883,18 @@ class Informatiq_SP_Admin {
}
// Get local price (sale price priority, then regular).
// Always calculate tax-inclusive price for comparison with Google (which is always tax-inclusive).
$sale_price = $product->get_sale_price();
$regular_price = $product->get_regular_price();
$local_price = ! empty( $sale_price ) ? $sale_price : $regular_price;
$base_price = ! empty( $sale_price ) ? $sale_price : $regular_price;
$price_type = ! empty( $sale_price ) ? 'sale' : 'regular';
// Get price including tax for fair comparison with Google.
$local_price = null;
if ( $base_price ) {
$local_price = wc_get_price_including_tax( $product, array( 'price' => $base_price ) );
}
// Try to find matching Google product.
$google_product = null;
$match_type = '';