Hello
Thank you for trying to help! Again my php is very limited. I edit existing things to try and make it work and can usually understand more or less what code is doing but I can’t write code myself.
I’ll try to explain my situation a bit better.
I have a Woocommerce plugin that shows products as a list (in a table) instead of separate boxes. This table has a cell for the “name” of the product. I want to have the content of a taxonomy as a second line under each name on each row.
So let’s say it is now (3 columns/row):
Row 1 : Name 1 | Rating | Add To Cart Button
Row 2 : Name 2 | Rating | Add To Cart Button
I want it to be:
Row1: Name 1 | Rating | Add To Cart Button
Taxonomy Country | |
Row2 : Name 2 | Rating | Add To Cart Button
Taxonomy Country | |
I did get this working years ago with a custom field using this line (in another plugin):
. get_post_meta( get_the_ID(), ‘Province’, true ) .
Now, with the new plugin that does the same thing but is a lot better I want to do the same but this time with a Taxonomy instead of a Custom Field. (This allows me to set up filters based on taxonomy which I cannot do with the custom field)
I found the php file and place where it searches for and displays the content in the “name cell”. Tried it out with just a plain “text” string and it showed “text” as I want it to as second line of each name cell. I then changed the code of the new plugin and added my old code (the . get_post_meta( get_the_ID(), ‘Province’, true ) . part) instead of the test string and again, works perfect… shows the content of the custom field for each row as second line in the name cell…
Now I used a plugin to add a custom taxonomy, called it “country” and edited all my products to have the correct data in that nex taxonomy.
All that remained was to change the line so that it reads the taxonomy instead of the custom field. And here is where I am stuck…
This is the full code for the custom field (works fine). I made bold the part I personally added to this code, the rest is native from the plugin:
private function get_product_name( $product ) {
$name = wcpt_get_name( $product ) . ‘’ . get_post_meta( get_the_ID(), ‘Province’, true ) . ‘’;
if ( array_intersect( array( ‘all’, ‘name’ ), $this->args->links ) ) {
$name = WCPT_Util::format_product_link( $product, $name );
}
return apply_filters( ‘wc_product_table_data_name’, $name, $product );
}
Hope this makes things clearer!