new ProductCatalogTemplate(), ProductCategoryTemplate::SLUG => new ProductCategoryTemplate(), ProductTagTemplate::SLUG => new ProductTagTemplate(), ProductAttributeTemplate::SLUG => new ProductAttributeTemplate(), ProductSearchResultsTemplate::SLUG => new ProductSearchResultsTemplate(), CartTemplate::SLUG => new CartTemplate(), CheckoutTemplate::SLUG => new CheckoutTemplate(), OrderConfirmationTemplate::SLUG => new OrderConfirmationTemplate(), SingleProductTemplate::SLUG => new SingleProductTemplate(), ); } else { $templates = array(); } if ( Features::is_enabled( 'launch-your-store' ) ) { $templates[ ComingSoonTemplate::SLUG ] = new ComingSoonTemplate(); } if ( BlockTemplateUtils::supports_block_templates( 'wp_template_part' ) ) { $template_parts = array( MiniCartTemplate::SLUG => new MiniCartTemplate(), CheckoutHeaderTemplate::SLUG => new CheckoutHeaderTemplate(), ); if ( Features::is_enabled( 'experimental-blocks' ) ) { $template_parts[ ProductFiltersTemplate::SLUG ] = new ProductFiltersTemplate(); $template_parts[ ProductFiltersOverlayTemplate::SLUG ] = new ProductFiltersOverlayTemplate(); } } else { $template_parts = array(); } $this->templates = array_merge( $templates, $template_parts ); // Init all templates. foreach ( $this->templates as $template ) { $template->init(); } } /** * Returns the template matching the slug * * @param string $template_slug Slug of the template to retrieve. * * @return AbstractTemplate|AbstractTemplatePart|null */ public function get_template( $template_slug ) { if ( array_key_exists( $template_slug, $this->templates ) ) { $registered_template = $this->templates[ $template_slug ]; return $registered_template; } return null; } }