Commit fa6eedcbc71 for woocommerce
commit fa6eedcbc7167a40b060f93499fdb79ced9cfa77
Author: Bero <1199991+bgrgicak@users.noreply.github.com>
Date: Tue Nov 3 08:29:03 2026 +0100
Fix sale price metadata for Meta catalogs (#70405)
* Fix Meta catalog sale price metadata
* Add changelog entry for sale price metadata
* Add product ID to Open Graph metadata
* Remove retailer item ID from product metadata
* Test the product price during a sale
* Restore product retailer ID metadata
diff --git a/plugins/woocommerce/changelog/fix-meta-sale-price b/plugins/woocommerce/changelog/fix-meta-sale-price
new file mode 100644
index 00000000000..332be5fd6e8
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-meta-sale-price
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Improve sale price details for products shared to Meta.
diff --git a/plugins/woocommerce/src/Internal/StructuredData/ProductOpenGraphTags.php b/plugins/woocommerce/src/Internal/StructuredData/ProductOpenGraphTags.php
index e4d4cfbe2ec..4240643cb10 100644
--- a/plugins/woocommerce/src/Internal/StructuredData/ProductOpenGraphTags.php
+++ b/plugins/woocommerce/src/Internal/StructuredData/ProductOpenGraphTags.php
@@ -41,6 +41,7 @@ class ProductOpenGraphTags {
array( 'og:type' => 'product' ),
array( 'og:url' => $product->get_permalink() ),
array( 'og:description' => wc_trim_string( $description ) ),
+ array( 'product:retailer_item_id' => (string) $product->get_id() ),
);
foreach ( $this->get_site_tags() as $property => $value ) {
$tags[] = array( $property => $value );
@@ -181,6 +182,8 @@ class ProductOpenGraphTags {
$tags['product:sale_price:amount'] = $price;
$tags['product:sale_price:currency'] = $currency;
$tags['og:price:standard_amount'] = wc_format_decimal( wc_get_price_to_display( $product, array( 'price' => $product->get_regular_price() ) ), wc_get_price_decimals() );
+ // Meta uses og:price:amount as the catalog price when both price aliases are present.
+ $tags['og:price:amount'] = $tags['og:price:standard_amount'];
foreach ( array(
'start' => $product->get_date_on_sale_from(),
'end' => $product->get_date_on_sale_to(),
diff --git a/plugins/woocommerce/tests/php/src/Internal/StructuredData/OpenGraphTest.php b/plugins/woocommerce/tests/php/src/Internal/StructuredData/OpenGraphTest.php
index 5ad84a54cb6..405af27bb8e 100644
--- a/plugins/woocommerce/tests/php/src/Internal/StructuredData/OpenGraphTest.php
+++ b/plugins/woocommerce/tests/php/src/Internal/StructuredData/OpenGraphTest.php
@@ -172,9 +172,10 @@ class OpenGraphTest extends WC_Unit_Test_Case {
$this->product->save();
$tags = $this->render_meta_tags( '' );
+ $this->assertSame( array( '8.00' ), $tags['product:price:amount'] );
$this->assertSame( array( '8.00' ), $tags['product:sale_price:amount'] );
$this->assertSame( array( 'USD' ), $tags['product:sale_price:currency'] );
- $this->assertSame( array( '8.00' ), $tags['og:price:amount'] );
+ $this->assertSame( array( '10.00' ), $tags['og:price:amount'] );
$this->assertSame( array( '10.00' ), $tags['og:price:standard_amount'] );
$this->assertSame( array( $this->product->get_date_on_sale_from()->format( DATE_ATOM ) ), $tags['product:sale_price_dates:start'] );
$this->assertSame( array( $this->product->get_date_on_sale_to()->format( DATE_ATOM ) ), $tags['product:sale_price_dates:end'] );