WC_Brands::wc_brands_on_block_template_register()publicWC 1.0

Add a new block to the template.

Method of the class: WC_Brands{}

No Hooks.

Return

null. Nothing (null).

Usage

$WC_Brands = new WC_Brands();
$WC_Brands->wc_brands_on_block_template_register( $template_id, $template_area, $template );
$template_id(string) (required)
Template ID.
$template_area(string) (required)
Template area.
$template(BlockTemplateInterface) (required)
Template instance.

WC_Brands::wc_brands_on_block_template_register() code WC 9.5.1

public function wc_brands_on_block_template_register( $template_id, $template_area, $template ) {

	if ( 'simple-product' === $template->get_id() ) {
		$section = $template->get_section_by_id( 'product-catalog-section' );
		if ( $section !== null ) {
			$section->add_block(
				array(
					'id'         => 'woocommerce-brands-select',
					'blockName'  => 'woocommerce/product-taxonomy-field',
					'order'      => 15,
					'attributes' => array(
						'label'       => __( 'Brands', 'woocommerce-brands' ),
						'createTitle' => __( 'Create new brand', 'woocommerce-brands' ),
						'slug'        => 'product_brand',
						'property'    => 'brands',
					),
				)
			);
		}
	}
}