Insert content of taxonomy in php
-
Hello
I got a Table list plugin for WooCommerce products. I want the content of a taxonomy (called “country”) to be displayed on the second row of every “product name cell”
I have a VERY hard time with this… this is my code so far.
private function get_product_name( $product ) { <strong>// Get all the country terms associated with $product. $terms = wp_get_post_terms($product->ID, 'country'); // Set the empty $country string. $country = ''; // Check if there are country terms available. if($terms){ // If there are terms then use the first one to populate the $country variable. $country = '</br><i>' . $terms[0]->name . '</i>'; } // Add $country to the $name variable.</strong> $name = wcpt_get_name( $product ) <strong>. $country . '</td>'</strong>; if ( array_intersect( [ 'all', 'name' ], $this->args->links ) ) { $name = WCPT_Util::format_product_link( $product, $name ); } return apply_filters( 'wc_product_table_data_name', $name, $product ); }
Now this code is from the Table view plugin PHP file where it populates the tables. I am trying to add the content of the taxonomy to this. I get no errors but it is not populating the “country” variable.
This is the original non edited function straight from the plugin:
private function get_product_name( $product ) { $name = wcpt_get_name( $product ); 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 ); }
What am I doing wrong ?
Viewing 10 replies - 1 through 10 (of 10 total)
Viewing 10 replies - 1 through 10 (of 10 total)
- The topic ‘Insert content of taxonomy in php’ is closed to new replies.