ueryArgs['posts_per_page'];
$totalProducts = absint( $products->found_posts );
$showMore = $limit > 0 && $totalProducts > 0 && $totalProducts - $limit > 0 ? true : false;
// Details panel title
$title .= '';
$title .= '';
$title .= Helpers::getLabel( 'tax_' . $taxonomy ) . ': ';
$title .= '';
$title .= esc_html( wp_unslash( $termName ) );
$title .= '';
$title = apply_filters( 'dgwt/wcas/suggestion_details/taxonomy/headline', $title, $termID, $taxonomy, $termName );
echo '
';
do_action( 'dgwt/wcas/details_panel/term_products/container_before' );
echo '
';
echo ! empty( $title ) ? $title : '';
$thumbSize = apply_filters( 'dgwt/wcas/suggestion_details/term_products/thumb_size', DGWT_WCAS()->setup->getThumbnailSize() );
$responsiveImages = apply_filters( 'dgwt/wcas/suggestion_details/responsive_images', true );
while ( $products->have_posts() ) {
$products->the_post();
$product = new Product( get_the_ID() );
if ( $product->isValid() ) {
$vars = array(
'ID' => $product->getID(),
'name' => $product->getName(),
'link' => apply_filters( 'dgwt/wcas/suggestion_details/term_product/url', $product->getPermalink(), $product ),
'imageSrc' => $product->getThumbnailSrc( $thumbSize ),
'imageSrcset' => $responsiveImages ? $product->getThumbnailSrcset( $thumbSize ) : '',
'imageSizes' => $responsiveImages ? $product->getThumbnailSizes( $thumbSize ) : '',
'reviewCount' => $product->getReviewCount(),
'ratingHtml' => $product->getRatingHtml(),
'priceHtml' => $product->getPriceHTML(),
'wooObject' => $product->getWooObject(),
);
$vars = (object) apply_filters( 'dgwt/wcas/suggestion_details/term_products/vars', $vars, $product->getID(), $product );
Helpers::loadTemplate( 'details-panel/term-product.php', $vars );
}
}
echo '
';
if ( $showMore ) {
$showMoreUrl = get_term_link( $termID, $taxonomy );
$showMoreUrl = apply_filters( 'dgwt/wcas/suggestion_details/term_products/show_more_url', $showMoreUrl, get_term( $termID, $taxonomy ) );
echo '
' . esc_html( Helpers::getLabel( 'show_more_details' ) ) . ' (' . $totalProducts . ')';
}
do_action( 'dgwt/wcas/details_panel/term_products/container_after' );
echo '
';
}
wp_reset_postdata();
$html = ob_get_clean();
return apply_filters( 'dgwt/wcas/suggestion_details/term/html', $html, $termID, $taxonomy );
}
/**
* Get query vars for products that should be displayed in the daxonomy details box
*
* @param int $termID
* @param string $taxonomy
*
* @return array
*/
private function getProductsQueryArgs( $termID, $taxonomy ) {
$productVisibilityTermIds = wc_get_product_visibility_term_ids();
$queryArgs = array(
'posts_per_page' => apply_filters( 'dgwt/wcas/suggestion_details/taxonomy/limit', 4 ),
'post_status' => 'publish',
'post_type' => 'product',
'no_found_rows' => false,
'order' => 'desc',
'orderby' => 'meta_value_num',
'meta_key' => 'total_sales',
'tax_query' => array()
);
// Visibility
$queryArgs['tax_query'][] = array(
'taxonomy' => 'product_visibility',
'field' => 'term_taxonomy_id',
'terms' => $productVisibilityTermIds['exclude-from-search'],
'operator' => 'NOT IN',
);
// Out of stock
if ( 'yes' === get_option( 'woocommerce_manage_stock' ) && DGWT_WCAS()->settings->getOption( 'exclude_out_of_stock' ) === 'on' ) {
$queryArgs['tax_query'][] = array(
'taxonomy' => 'product_visibility',
'field' => 'term_taxonomy_id',
'terms' => $productVisibilityTermIds['outofstock'],
'operator' => 'NOT IN',
);
};
// Search with specific category
$queryArgs['tax_query'][] = array(
'taxonomy' => $taxonomy,
'field' => 'id',
'terms' => $termID,
'include_children' => true,
);
return apply_filters( 'dgwt/wcas/suggestion_details/taxonomy/products_query_args', $queryArgs, $termID, $taxonomy );
}
}