Automattic\WooCommerce\Blocks\BlockTypes\AddToCartWithOptions

AddToCartWithOptions::get_template_part_ids │ protected │ WC 1.0

Get template part IDs for each product type.

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

Хуков нет.

Возвращает

array. Array of product types with their corresponding template part IDs.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_template_part_ids();

Код AddToCartWithOptions::get_template_part_ids() WC 11.2.1

protected function get_template_part_ids() {
	$product_types = array_keys( wc_get_product_types() );
	$current_theme = wp_get_theme()->get_stylesheet();

	$template_part_ids = array();
	foreach ( $product_types as $product_type ) {
		$slug = $product_type . '-product-add-to-cart-with-options';

		// Check if theme template exists.
		$theme_has_template = BlockTemplateUtils::theme_has_template_part( $slug );

		if ( $theme_has_template ) {
			$template_part_ids[ $product_type ] = "{$current_theme}//{$slug}";
		} else {
			$template_part_ids[ $product_type ] = "woocommerce/woocommerce//{$slug}";
		}
	}

	return $template_part_ids;
}