Commit cbbdf7b0bf6 for woocommerce
commit cbbdf7b0bf6b6d95a95ba8e3e29c12e1fe638877
Author: Jorge A. Torres <jorge.torres@automattic.com>
Date: Mon Aug 10 17:06:09 2026 +0100
Avoid a PHP warning when a Marketplace subscription is missing product type (#67571)
diff --git a/plugins/woocommerce/includes/admin/helper/class-wc-helper-subscriptions-api.php b/plugins/woocommerce/includes/admin/helper/class-wc-helper-subscriptions-api.php
index 077e968b917..731d1672f73 100644
--- a/plugins/woocommerce/includes/admin/helper/class-wc-helper-subscriptions-api.php
+++ b/plugins/woocommerce/includes/admin/helper/class-wc-helper-subscriptions-api.php
@@ -303,15 +303,6 @@ class WC_Helper_Subscriptions_API {
);
}
- if ( ! in_array( $subscription['product_type'], array( 'plugin', 'theme' ), true ) ) {
- wp_send_json_error(
- array(
- 'message' => __( 'This product type is not supported.', 'woocommerce' ),
- ),
- 400
- );
- }
-
if ( true !== $subscription['local']['installed'] || ! isset( $subscription['local']['active'] ) ) {
wp_send_json_error(
array(
@@ -329,6 +320,15 @@ class WC_Helper_Subscriptions_API {
);
}
+ if ( ! in_array( $subscription['product_type'] ?? null, array( 'plugin', 'theme' ), true ) ) {
+ wp_send_json_error(
+ array(
+ 'message' => __( 'This product type is not supported.', 'woocommerce' ),
+ ),
+ 400
+ );
+ }
+
if ( 'plugin' === $subscription['product_type'] ) {
// manage_woocommerce (checked by get_permission() above) doesn't imply activate_plugins.
if ( ! current_user_can( 'activate_plugins' ) ) {