Automattic\WooCommerce\Blocks\BlockTypes\AddToCartWithOptions
AddToCartWithOptions::get_template_part_ids
Get template part IDs for each product type.
Method of the class: AddToCartWithOptions{}
No Hooks.
Returns
Array. Array of product types with their corresponding template part IDs.
Usage
// protected - for code of main (parent) or child class $result = $this->get_template_part_ids();
AddToCartWithOptions::get_template_part_ids() AddToCartWithOptions::get template part ids code WC 10.7.0
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;
}