' ;
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-product-suggestion' );
$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' => $product->getPermalink(),
'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 );
echo '
' . 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
);
}
}