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:
@@ -883,11 +883,18 @@ class Informatiq_SP_Admin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get local price (sale price priority, then regular).
|
// 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();
|
$sale_price = $product->get_sale_price();
|
||||||
$regular_price = $product->get_regular_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';
|
$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.
|
// Try to find matching Google product.
|
||||||
$google_product = null;
|
$google_product = null;
|
||||||
$match_type = '';
|
$match_type = '';
|
||||||
|
|||||||
Reference in New Issue
Block a user