function devise_hide_attributes_from_additional_info_tabs( $attributes, $product ) {
$hidden_attributes = [
'pa_network',
'pa_merchant',
'pa_brand',
];
foreach ( $hidden_attributes as $hidden_attribute ) {
if ( ! isset( $attributes[ $hidden_attribute ] ) ) {
continue;
}
$attribute = $attributes[ $hidden_attribute ];
$attribute->set_visible( false );
}
return $attributes;
}
add_filter( 'woocommerce_product_get_attributes', 'devise_hide_attributes_from_additional_info_tabs', 20, 2 );
$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 '<h6 class="category">';
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 '<a href="' . esc_url( get_term_link( $product_cat_id, 'product_cat' ) ) . '">' . esc_html( $product_cat_name ) . '</a>';
$i = true;
}
$index ++;
}
}
echo '</h6>';
}
public function the_attributes( $product = null, $element, $show_weight = null, $show_dimensions = null, $skip_atts = null, $single_product = null ) {
$out = '';
$out_middle = '';
if ( isset( $product ) ) {
if ( is_object( $product ) ) {
if ( $show_weight ) {
if ( $product->has_weight() ) {
$weight = $product->get_weight();
$unit = esc_attr( get_option( 'woocommerce_weight_unit' ) );
}
}
$out_middle .= ' <table><tbody>';
if ( $show_dimensions ) {
if ( $product->has_dimensions() ) {
$dimensions = wc_format_dimensions( $product->get_dimensions( false ) );
}
}
$colon = get_option( 'wcsa_remove_semicolon' ) == 'yes' ? ' ' : ': ';
$hide_labels = get_option( 'woocommerce_show_attributes_hide_labels' );
// check if they choose span element over li
if ( get_option( 'woocommerce_show_attributes_span' ) == 'yes' ) {
$element = 'span';
}
if ( ! $skip_atts ) {
$attributes = $this->get_attributes( $product, $single_product );
if ( ! $attributes ) {
return;
}
foreach ( $attributes as $attribute ) {
$class_string = sanitize_title( strip_tags( $attribute['value'] ) );
$out_middle .= '<' . esc_attr( $element ) . ' class="' . esc_attr( sanitize_title( $attribute['label'] ) ) . ' ' . esc_attr( $class_string ) . '">';
// Hide labels if they want to
if ( 'yes' != $hide_labels ) {
// PolyLang translation support
if ( function_exists( 'pll__' ) ) {
$translation = pll__( $attribute['label'] );
$attribute['label'] = ( ! empty( $translation ) ) ? $translation : $attribute['label'];
}
// WPML translation support
if ( defined( 'ICL_LANGUAGE_CODE' ) ) {
$translation = apply_filters( 'wpml_translate_single_string', $attribute['label'], 'WordPress', 'taxonomy singular name: '. $attribute['label'] );
$attribute['label'] = ( ! empty( $translation ) ) ? $translation : $attribute['label'];
}
}
{
$out_middle .= '<tr><td><span class="attribute-label"> ' .
sprintf( __( '%s', '<b>woocommerce-show-attributes</b>' ), esc_html( $attribute['label'] ) )
. '</td></span>' . $colon ;
$out_middle .= '<td><span class="attribute-value">';
$out_middle .= $attribute['value'];
$out_middle .= '</span></td></tr></' . esc_attr( $element ) . '>';
}
} // ends foreach attribute
}
// Add weight and dimensions if they opted in
if ( ! empty( $weight ) ) {
$unit = empty( $unit ) ? '' : $unit;
// weight
$out_middle .= '<' . esc_attr( $element ) . ' class="show-attributes-weight">';
// Hide labels if they want to
if ( $hide_labels != 'yes' ) {
$out_middle .= '<span class="attribute-label">' . __( 'Weight', 'woocommerce-show-attributes' ) . $colon . ' </span> ';
}
$out_middle .= '<span class="attribute-value">' . esc_html( $weight ) . ' ' . esc_html( $unit ) . ' </span></' . esc_attr( $element ) . '>';
if ( 'span' == $element ) {
$out_middle .= '<br />';
}
}
if ( ! empty( $dimensions ) ) {
// dimensions
$out_middle .= '<' . esc_attr( $element ) . ' class="show-attributes-dimensions">';
// Hide labels if they want to
if ( $hide_labels != 'yes' ) {
$out_middle .= '<span class="attribute-label">' . __( 'Dimensions', 'woocommerce-show-attributes' ) . $colon . ' </span> ';
}
$out_middle .= '<span class="attribute-value">' . esc_html( $dimensions ) . '</span></' . esc_attr( $element ) . '>';
if ('span' == $element) {
$out_middle .= '<br />';
}
}
$out_middle .= (' </tbody></table>');
if ( $out_middle ) {
$out = ('li' == $element) ? '<ul ' : '<div ';
$out .= 'class="attribut">' . $out_middle;
$out .= ('li' == $element) ? '</ul>' : '</div>';
}
}
}
return $out;
}