/**
* Change the main content for single product listing
*/
function hestia_woocommerce_template_loop_product_title() {
global $post;
$current_product = wc_get_product( get_the_ID() );
?>
<?php
$product_categories = get_the_terms( $post->ID, 'product_cat' );
$i = false;
if ( ! empty( $product_categories ) && apply_filters( 'hestia_show_category_on_product_card', true ) ) {
/**
* Show only the first $nb_of_cat words. If the value is modified in hestia_shop_category_words filter with
* something lower than 0 then it will display all categories.
*/
$nb_of_cat = apply_filters( 'hestia_shop_category_words', 2 );
$nb_of_cat = intval( $nb_of_cat );
$index = 0;
if ( $nb_of_cat !== 0 ) {
echo '';
foreach ( $product_categories as $product_category ) {
if ( $index < $nb_of_cat || $nb_of_cat < 0 ) {
$product_cat_id = $product_category->term_id;
$product_cat_name = $product_category->name;
if ( ! empty( $product_cat_id ) && ! empty( $product_cat_name ) ) {
if ( $i ) {
echo ' , ';
}
echo '
' . esc_html( $product_cat_name ) . '';
$i = true;
}
$index ++;
}
}
echo '';
}
}
?>
<?php
/**
* Explode title in words by ' ' separator and show only the first 6 words. If the value is modified to -1 or lower in
* a function hooked at hestia_shop_title_words, then show the full title
*/
$title = the_title( '', '', false );
$title_in_words = explode( ' ', $title );
$title_limit = apply_filters( 'hestia_shop_title_words', - 1 );
$title_limit = intval( $title_limit );
$limited_title = $title_limit > - 1 ? hestia_limit_content( $title_in_words, $title_limit, ' ' ) : $title;
?>
<?php echo esc_html( $limited_title ); ?>
<?php
if ( $post->post_excerpt ) :
/**
* Explode the excerpt in words by ' ' separator and show only the first 60 words. If the value is modified to -1 or lower in
* a function hooked at hestia_shop_excerpt_words, then use the normal behavior from woocommece ( show post excerpt )
*/
$excerpt_in_words = explode( ' ', $post->post_excerpt );
$excerpt_limit = apply_filters( 'hestia_shop_excerpt_words', 60 );
$excerpt_limit = intval( $excerpt_limit );
$limited_excerpt = $excerpt_limit > - 1 ? hestia_limit_content( $excerpt_in_words, $excerpt_limit, ' ' ) : $post->post_excerpt;
?>
<?php echo wp_kses_post( apply_filters( 'woocommerce_short_description', $limited_excerpt ) ); ?>
<?php endif; ?>
<?php
$product_price = $current_product->get_price_html();
if ( ! empty( $product_price ) ) {
echo '';
echo wp_kses(
$product_price,
array(
'span' => array(
'class' => array(),
),
'del' => array(),
)
);
echo '';
}
?>
<?php hestia_add_to_cart(); ?>
<?php
}