Automattic\WooCommerce\Admin\Features\ProductBlockEditor
Init::possibly_add_template_id
Adds the product template ID to the product if it doesn't exist.
Method of the class: Init{}
Hooks from the method
Returns
null. Nothing (null).
Usage
$Init = new Init(); $Init->possibly_add_template_id( $response, $product );
- $response(WP_REST_Response) (required)
- The response object.
- $product(WC_Product) (required)
- The product.
Init::possibly_add_template_id() Init::possibly add template id code WC 10.5.0
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;
}