Answer the question
In order to leave comments, you need to log in
Remove word "Product" from woocommerce attribute name?
There is such a function
function productFeature() {
global $post;
$attribute_names = array( 'pa_razmer-domika', 'pa_materialy' , 'pa_ves-v-sobrannom-vide' );
echo '<span class="attribute">';
foreach ( $attribute_names as $attribute_name ) {
$taxonomy = get_taxonomy( $attribute_name );
if ( $taxonomy && ! is_wp_error( $taxonomy ) ) {
$terms = wp_get_post_terms( $post->ID, $attribute_name );
$terms_array = array();
if ( ! empty( $terms ) ) {
foreach ( $terms as $term ) {
$full_line = '<span>'. $term->name . '</span>';
array_push( $terms_array, $full_line );
}
echo '<span class="attribute_item">' . $taxonomy->labels->name . ' ' . implode( $terms_array, ', ' ). '</span>';
}
}
}
echo '</span>';
}
// Определяем место вывода атрибута
add_action('woocommerce_single_product_summary', 'productFeature', 7);
Answer the question
In order to leave comments, you need to log in
Well, I would just replace the product with an empty space...
If I didn't make a mistake with the variable, then something like this:
function productFeature() {
global $post;
$attribute_names = array( 'pa_razmer-domika', 'pa_materialy' , 'pa_ves-v-sobrannom-vide' );
echo '<span class="attribute">';
foreach ( $attribute_names as $attribute_name ) {
$taxonomy = get_taxonomy( $attribute_name );
if ( $taxonomy && ! is_wp_error( $taxonomy ) ) {
$terms = wp_get_post_terms( $post->ID, $attribute_name );
$terms_array = array();
if ( ! empty( $terms ) ) {
foreach ( $terms as $term ) {
$full_line = '<span>'. $term->name . '</span>';
array_push( $terms_array, $full_line );
}
$tovar_name = str_replace('Товар ', '', $taxonomy->labels->name);
echo '<span class="attribute_item">' . $tovar_name . ' ' . implode( $terms_array, ', ' ). '</span>';
}
}
}
echo '</span>';
}
// Определяем место вывода атрибута
add_action('woocommerce_single_product_summary', 'productFeature', 7);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question