Merge pull request #19160 from woocommerce/fix/19112
Set is_tax to true when on unsupported theme taxonomy archive
This commit is contained in:
commit
bb94d2467f
|
@ -275,7 +275,9 @@ class WC_Template_Loader {
|
|||
$prefix = '';
|
||||
}
|
||||
|
||||
add_filter( 'woocommerce_shortcode_products_query', array( __CLASS__, 'unsupported_archive_layered_nav_compatibility' ) );
|
||||
$shortcode = new WC_Shortcode_Products( $shortcode_args );
|
||||
remove_filter( 'woocommerce_shortcode_products_query', array( __CLASS__, 'unsupported_archive_layered_nav_compatibility' ) );
|
||||
$shop_page = get_post( self::$shop_page_id );
|
||||
|
||||
$dummy_post_properties = array(
|
||||
|
@ -318,7 +320,7 @@ class WC_Template_Loader {
|
|||
$wp_query->is_page = true;
|
||||
$wp_query->is_single = true;
|
||||
$wp_query->is_archive = false;
|
||||
$wp_query->is_tax = false;
|
||||
$wp_query->is_tax = true;
|
||||
$wp_query->max_num_pages = 0;
|
||||
|
||||
// Prepare everything for rendering.
|
||||
|
@ -328,6 +330,26 @@ class WC_Template_Loader {
|
|||
add_filter( 'template_include', array( __CLASS__, 'force_single_template_filter' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add layered nav args to WP_Query args generated by the 'products' shortcode.
|
||||
*
|
||||
* @since 3.3.4
|
||||
* @param array $query WP_Query args.
|
||||
* @return array
|
||||
*/
|
||||
public static function unsupported_archive_layered_nav_compatibility( $query ) {
|
||||
foreach ( WC()->query->get_layered_nav_chosen_attributes() as $taxonomy => $data ) {
|
||||
$query['tax_query'][] = array(
|
||||
'taxonomy' => $taxonomy,
|
||||
'field' => 'slug',
|
||||
'terms' => $data['terms'],
|
||||
'operator' => 'and' === $data['query_type'] ? 'AND' : 'IN',
|
||||
'include_children' => false,
|
||||
);
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Force the loading of one of the single templates instead of whatever template was about to be loaded.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue