Commit 33de335562c for woocommerce

commit 33de335562c89180cc9d44917a6ba780dd1ddb8a
Author: Tung Du <dinhtungdu@gmail.com>
Date:   Thu Nov 12 08:17:39 2026 +0700

    Respect product passwords in Store API cart and order item descriptions (#70844)

    * Respect product passwords in Store API cart and order item descriptions

    Cart and order items now return empty descriptions for password
    protected products, the same as the products route.

    * Format cart and order item descriptions inside the password check

    This matches ProductSchema, so the same-product recursion check also
    covers shortcodes in the description.

    Amp-Thread-ID: https://ampcode.com/threads/T-c8595550-132d-4c7c-84eb-dd6aba3f9a7d
    Co-authored-by: Amp <amp@ampcode.com>

    * Keep formatting empty order item descriptions when the product is gone

    Filters on woocommerce_format_content still run on the empty defaults,
    as they did before.

    Amp-Thread-ID: https://ampcode.com/threads/T-c8595550-132d-4c7c-84eb-dd6aba3f9a7d
    Co-authored-by: Amp <amp@ampcode.com>

    * Revert "Keep formatting empty order item descriptions when the product is gone"

    This reverts commit 41c4deb5ef5906b2ad317decdfde0460514a7b7d.

    ---------

    Co-authored-by: Amp <amp@ampcode.com>

diff --git a/plugins/woocommerce/changelog/fix-store-api-item-description-password b/plugins/woocommerce/changelog/fix-store-api-item-description-password
new file mode 100644
index 00000000000..dd2064cfd38
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-store-api-item-description-password
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Cart and order item descriptions in the Store API now respect product passwords.
diff --git a/plugins/woocommerce/src/StoreApi/Schemas/V1/CartItemSchema.php b/plugins/woocommerce/src/StoreApi/Schemas/V1/CartItemSchema.php
index 938bdc963e4..6ce275efaed 100644
--- a/plugins/woocommerce/src/StoreApi/Schemas/V1/CartItemSchema.php
+++ b/plugins/woocommerce/src/StoreApi/Schemas/V1/CartItemSchema.php
@@ -1,6 +1,7 @@
 <?php
 namespace Automattic\WooCommerce\StoreApi\Schemas\V1;

+use Automattic\WooCommerce\Blocks\Utils\ProductDescriptionUtils;
 use Automattic\WooCommerce\StoreApi\Utilities\ProductItemTrait;
 use Automattic\WooCommerce\StoreApi\Utilities\QuantityLimits;

@@ -80,8 +81,22 @@ class CartItemSchema extends ItemSchema {
 			'quantity'             => wc_stock_amount( $cart_item['quantity'] ),
 			'quantity_limits'      => (object) ( new QuantityLimits() )->get_cart_item_quantity_limits( $cart_item ),
 			'name'                 => $this->prepare_html_response( $product->get_title() ),
-			'short_description'    => $this->prepare_html_response( wc_format_content( wp_kses_post( $product->get_short_description() ) ) ),
-			'description'          => $this->prepare_html_response( wc_format_content( wp_kses_post( $product->get_description() ) ) ),
+			'short_description'    => $this->prepare_html_response(
+				ProductDescriptionUtils::guarded_format(
+					$product,
+					function () use ( $product ) {
+						return wc_format_content( wp_kses_post( $product->get_short_description() ) );
+					}
+				)
+			),
+			'description'          => $this->prepare_html_response(
+				ProductDescriptionUtils::guarded_format(
+					$product,
+					function () use ( $product ) {
+						return wc_format_content( wp_kses_post( $product->get_description() ) );
+					}
+				)
+			),
 			'sku'                  => $this->prepare_html_response( $product->get_sku() ),
 			'low_stock_remaining'  => $this->get_low_stock_remaining( $product ),
 			'backorders_allowed'   => (bool) $product->backorders_allowed(),
diff --git a/plugins/woocommerce/src/StoreApi/Schemas/V1/OrderItemSchema.php b/plugins/woocommerce/src/StoreApi/Schemas/V1/OrderItemSchema.php
index 62d96adc0db..727a2376a51 100644
--- a/plugins/woocommerce/src/StoreApi/Schemas/V1/OrderItemSchema.php
+++ b/plugins/woocommerce/src/StoreApi/Schemas/V1/OrderItemSchema.php
@@ -1,6 +1,7 @@
 <?php
 namespace Automattic\WooCommerce\StoreApi\Schemas\V1;

+use Automattic\WooCommerce\Blocks\Utils\ProductDescriptionUtils;
 use Automattic\WooCommerce\StoreApi\Utilities\ProductItemTrait;

 /**
@@ -193,8 +194,18 @@ class OrderItemSchema extends ItemSchema {
 		];

 		if ( is_a( $product, 'WC_Product' ) ) {
-			$product_properties['short_description']  = $product->get_short_description();
-			$product_properties['description']        = $product->get_description();
+			$product_properties['short_description']  = ProductDescriptionUtils::guarded_format(
+				$product,
+				function () use ( $product ) {
+					return wc_format_content( wp_kses_post( $product->get_short_description() ) );
+				}
+			);
+			$product_properties['description']        = ProductDescriptionUtils::guarded_format(
+				$product,
+				function () use ( $product ) {
+					return wc_format_content( wp_kses_post( $product->get_description() ) );
+				}
+			);
 			$product_properties['sku']                = $product->get_sku();
 			$product_properties['permalink']          = $product->get_permalink();
 			$product_properties['catalog_visibility'] = $product->get_catalog_visibility();
@@ -220,8 +231,8 @@ class OrderItemSchema extends ItemSchema {
 				'editable'    => false,
 			),
 			'name'                 => $order_item->get_name(),
-			'short_description'    => $this->prepare_html_response( wc_format_content( wp_kses_post( $product_properties['short_description'] ) ) ),
-			'description'          => $this->prepare_html_response( wc_format_content( wp_kses_post( $product_properties['description'] ) ) ),
+			'short_description'    => $this->prepare_html_response( $product_properties['short_description'] ),
+			'description'          => $this->prepare_html_response( $product_properties['description'] ),
 			'sku'                  => $this->prepare_html_response( $product_properties['sku'] ),
 			'low_stock_remaining'  => null,
 			'backorders_allowed'   => false,