Automattic\WooCommerce\Admin\Features\ProductBlockEditor

Init::possibly_add_template_id()publicWC 1.0

Adds the product template ID to the product if it doesn't exist.

Метод класса: Init{}

Возвращает

null. Ничего (null).

Использование

$Init = new Init();
$Init->possibly_add_template_id( $response, $product );
$response(WP_REST_Response) (обязательный)
The response object.
$product(WC_Product) (обязательный)
The product.

Код Init::possibly_add_template_id() WC 9.7.1

public function possibly_add_template_id( $response, $product ) {
	if ( ! $product ) {
		return $response;
	}
	if ( ! $product->meta_exists( '_product_template_id' ) ) {
		/**
		 * Experimental: Allows to determine a product template id based on the product data.
		 *
		 * @ignore
		 * @since 9.1.0
		 */
		$product_template_id = apply_filters( 'experimental_woocommerce_product_editor_product_template_id_for_product', '', $product );
		if ( $product_template_id ) {
			$response->data['meta_data'][] = new WC_Meta_Data(
				array(
					'key'   => '_product_template_id',
					'value' => $product_template_id,
				)
			);
		}
	}
	return $response;
}