Use the archive-product template to render product attributes pages (https://github.com/woocommerce/woocommerce-blocks/pull/6776)
This commit is contained in:
parent
3858b03aec
commit
ef13f65dc0
|
@ -425,6 +425,11 @@ class BlockTemplatesController {
|
|||
$this->block_template_is_available( 'taxonomy-product_tag' )
|
||||
) {
|
||||
add_filter( 'woocommerce_has_block_template', '__return_true', 10, 0 );
|
||||
} elseif ( taxonomy_is_product_attribute( get_query_var( 'taxonomy' ) ) &&
|
||||
! BlockTemplateUtils::theme_has_template( 'archive-product' ) &&
|
||||
$this->block_template_is_available( 'archive-product' )
|
||||
) {
|
||||
add_filter( 'woocommerce_has_block_template', '__return_true', 10, 0 );
|
||||
} elseif (
|
||||
( is_post_type_archive( 'product' ) || is_page( wc_get_page_id( 'shop' ) ) ) &&
|
||||
! BlockTemplateUtils::theme_has_template( 'archive-product' ) &&
|
||||
|
|
|
@ -22,6 +22,7 @@ use Automattic\WooCommerce\Blocks\Payments\Integrations\Cheque;
|
|||
use Automattic\WooCommerce\Blocks\Payments\Integrations\PayPal;
|
||||
use Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry;
|
||||
use Automattic\WooCommerce\Blocks\Registry\Container;
|
||||
use Automattic\WooCommerce\Blocks\Templates\ProductAttributeTemplate;
|
||||
use Automattic\WooCommerce\StoreApi\StoreApi;
|
||||
use Automattic\WooCommerce\StoreApi\RoutesController;
|
||||
use Automattic\WooCommerce\StoreApi\SchemaController;
|
||||
|
@ -116,6 +117,7 @@ class Bootstrap {
|
|||
$this->container->get( BlockTypesController::class );
|
||||
$this->container->get( BlockTemplatesController::class );
|
||||
$this->container->get( ProductSearchResultsTemplate::class );
|
||||
$this->container->get( ProductAttributeTemplate::class );
|
||||
$this->container->get( ClassicTemplatesCompatibility::class );
|
||||
if ( $this->package->feature()->is_feature_plugin_build() ) {
|
||||
$this->container->get( PaymentsApi::class );
|
||||
|
@ -249,6 +251,12 @@ class Bootstrap {
|
|||
return new ProductSearchResultsTemplate();
|
||||
}
|
||||
);
|
||||
$this->container->register(
|
||||
ProductAttributeTemplate::class,
|
||||
function () {
|
||||
return new ProductAttributeTemplate();
|
||||
}
|
||||
);
|
||||
$this->container->register(
|
||||
ClassicTemplatesCompatibility::class,
|
||||
function ( Container $container ) {
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Templates;
|
||||
|
||||
/**
|
||||
* ProductAttributeTemplate class.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ProductAttributeTemplate {
|
||||
const SLUG = 'archive-product';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization method.
|
||||
*/
|
||||
protected function init() {
|
||||
add_filter( 'taxonomy_template_hierarchy', array( $this, 'update_taxonomy_template_hierarchy' ), 10, 3 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the Archive Product Template for product attributes.
|
||||
*
|
||||
* @param array $templates Templates that match the product attributes taxonomy.
|
||||
*/
|
||||
public function update_taxonomy_template_hierarchy( $templates ) {
|
||||
if ( taxonomy_is_product_attribute( get_query_var( 'taxonomy' ) ) && wc_current_theme_is_fse_theme() ) {
|
||||
array_unshift( $templates, self::SLUG );
|
||||
}
|
||||
|
||||
return $templates;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue