Add brand to product tile
-
Hi, now we have the title on a single page made like this:
Product Attribute (producer) + Product Title
We would like to replace the producer attribute to brand and maintain the display style. Also remove additional brand displaying in different place on single page.
How can we do that ?
This is our current funcion:
remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_title’, 5 );
add_action( ‘woocommerce_single_product_summary’, ‘custom_template_single_title’, 5 );
function custom_template_single_title() {
global $product;
global $post;$brand_name = $product->get_attribute(‘pa_producent’);
$rocznik = $product->get_attribute(‘pa_rocznik’);
$kraj = $product->get_attribute(‘pa_kraj’);
if( $brand_name ) {
$attribute_names = array( ‘pa_producent’);
echo ‘<h1 class=”product_title entry-title”><span class=”head-producent”>’;
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 ) {
$archive_link = get_term_link( $term->slug, $attribute_name );
$full_line = ‘‘. $term->name . ‘‘;
array_push( $terms_array, $full_line );
}echo $taxonomy = implode( $terms_array, ‘, ‘ );
}
}
}
echo ‘</span> ‘; }
else {
echo ‘<h1 class=”product_title entry-title”>’; }
the_title();
echo ‘</h1>’;
echo ‘<h5>’;
if( $rocznik ) {
echo ‘<i class=”fad fa-seedling”></i> ‘ . $rocznik . ‘ ‘; }
if( $kraj ) {
$attribute_names = array( ‘pa_kraj’);
echo ‘<i class=”fad fa-globe-europe”></i> ‘;
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 ) {
$archive_link = get_term_link( $term->slug, $attribute_name );
$full_line = ‘‘. $term->name . ‘‘;
array_push( $terms_array, $full_line );
}echo $taxonomy = implode( $terms_array, ‘, ‘ );
}
}
}
echo ”;}
echo ‘</h5>’;
}The page I need help with: [log in to see the link]
- The topic ‘Add brand to product tile’ is closed to new replies.