Hello,
i got a taxonomy ‘product_options’, the tax terms had an acf field ‘price’ and i want to display this price on product edit, is it possible?
Thanks
Hi @artisancodeur
You can get the value from ACF fields assigned to Taxonomies by passing the term as a second parameter to the get_field() function.
Please take a look at the following resource page: https://www.advancedcustomfields.com/resources/get-values-from-a-taxonomy-term/
Thanks for reply, but i don’t know how to hook the acf taxonomie template list(in admin-> edit product or post or something) sorry i don’t know if i’m precise.
Hi @artisancodeur
Thanks for the clarification. To change the text displayed on the admin, you can hook into acf/fields/taxonomy/result filter and then fetch the values of the custom fields containing the price.
The code would look something like this:
<?php
function my_relationship_result( $title, $term, $field, $post_id ) {
// load a custom field from this $object and show it in the $result
$price = get_field('price', $post->ID);
// append to title
$title .= ' [' . $rice . ']';
// return
return $title;
}
// filter for a specific field based on it's name
//add_filter('acf/fields/taxonomy/result/name=my_taxonomy', 'my_relationship_result', 10, 4);
?>
Hi,
Perfect ! It’s was exactly what i’m needing.
thanks a lot !