Commit 93d6a14fb08 for woocommerce
commit 93d6a14fb084e049e45e164528d18000e601f59e
Author: Tung Du <dinhtungdu@gmail.com>
Date: Thu Oct 29 22:28:38 2026 +0700
Improve variation AJAX consistency with the product page (#70369)
fix: align get_variation AJAX response with product password setting
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
diff --git a/plugins/woocommerce/changelog/fix-variation-ajax-consistency b/plugins/woocommerce/changelog/fix-variation-ajax-consistency
new file mode 100644
index 00000000000..5c1c8ea6b97
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-variation-ajax-consistency
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Make variation details loaded on the product page follow the product password setting.
diff --git a/plugins/woocommerce/includes/class-wc-ajax.php b/plugins/woocommerce/includes/class-wc-ajax.php
index 8de169c384f..3d25d949022 100644
--- a/plugins/woocommerce/includes/class-wc-ajax.php
+++ b/plugins/woocommerce/includes/class-wc-ajax.php
@@ -673,6 +673,11 @@ class WC_AJAX {
wp_die();
}
+ // Match the product page, which shows variation details only after the product password is entered.
+ if ( post_password_required( $variable_product->get_id() ) ) {
+ wp_die();
+ }
+
$data_store = WC_Data_Store::load( 'product' );
$variation_id = $data_store->find_matching_product_variation( $variable_product, wp_unslash( $_POST ) );
$variation = $variation_id ? $variable_product->get_available_variation( $variation_id ) : false;