WC_Brands::wc_brands_on_block_template_register
Add a new block to the template.
Метод класса: WC_Brands{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$WC_Brands = new WC_Brands(); $WC_Brands->wc_brands_on_block_template_register( $template_id, $template_area, $template );
- $template_id(строка) (обязательный)
- Template ID.
- $template_area(строка) (обязательный)
- Template area.
- $template(BlockTemplateInterface) (обязательный)
- Template instance.
Код WC_Brands::wc_brands_on_block_template_register() WC Brands::wc brands on block template register WC 10.4.3
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',
),
)
);
}
}
}