## theme development – Add additional information when displying attribute with a hook on single product page

Question

I have books as products in woocommerce and I’m trying to show the order of the book in the series. It should look something like this:

“The book 1 of Series”

I’ve managed to add the link to the series archive but I can’t work out the code to add the rest. The number showing the order in the series is an attribute with the slug “series-order”.

The example of the page (the series name is under the book name): https://tillysbooks.com/product/a-column-of-fire/

The code I have so far is:

/* Display book series archive links on the shop page
*/

function tilly_show_book_series() {
global $post;$attribute_names = array( 'pa_book-series' );

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="<a href="" .$archive_link . '">'. $term->name . '</a>'; array_push($terms_array, $full_line ); } echo implode($terms_array, ', ' );
}
}
}
}



I have basic knowledge of PHP and actions and filters and learning while amending Storefront theme.

Thank you very much for your help!!!

0
3 weeks 2023-03-05T13:13:40-05:00 0 Answers 0 views 0