WC_Helper_Updater::get_product_id_from_update_response │ private static │ WC 11.2.0

Product ID carried by an update response WooCommerce wrote, or 0 for anything else.

The updater sets the ID to "woocommerce-com-<product ID>". A filter can replace the response, so anything that does not match exactly is treated as not ours rather than having its digits scraped out.

Method of the class: WC_Helper_Updater{}

No Hooks.

Returns

int.

Usage

$result = WC_Helper_Updater::get_product_id_from_update_response( $response ): int;
$response(mixed) (required)
Update response from the update_plugins transient.

Changelog

Since 11.2.0 Introduced.

WC_Helper_Updater::get_product_id_from_update_response() code WC 11.2.2

private static function get_product_id_from_update_response( $response ): int {
	if ( ! is_object( $response ) || ! isset( $response->id ) || ! is_string( $response->id ) ) {
		return 0;
	}

	$prefix = 'woocommerce-com-';
	if ( 0 !== strpos( $response->id, $prefix ) ) {
		return 0;
	}

	$product_id = substr( $response->id, strlen( $prefix ) );

	return ctype_digit( $product_id ) ? (int) $product_id : 0;
}