Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Carlo Cannavò

Woocommerce Variation – Column Hook

Hi Team,
i have added the same ACF field in Woocommerce Products Columns and in your extend view of “Woocommerce Variation products”.

After that i am using this hook to display other info in that column:

function add_product_minprice_content( $column, $postid ) {

//this is id of column in woocommerce product
if ( $column == '6166863e0c8b44' ) {
  ..my code here echo "blah blah"
 }
//this is id of colum inside variations
if ( $column == '616685f5bba5e4' ) {
  ..my code here echo "blah blah"
 }

}
add_action( 'manage_product_posts_custom_column', 'add_product_minprice_content', 10, 2 );

and it work normally in woocommerce product column,
intead in your woocommerce variation columns not.

How can i edit to use also your extended view ?
Thanks

2 years, 6 months ago
Carlo Cannavò

Reading the hook documentation I was able to fix it on my own.

Place the code in case someone should need it:

function ac_column_value_acf_example_2( $value, $id, AC\Column $column ) {
// Check for the ACF column
if ( $column instanceof ACA\ACF\Column ) {
$meta_key = $column->get_meta_key();
if (‘my_field_label’ === $meta_key) {
//my code here
$value .= “append value here”;
}
}
return $value;
}
add_filter( ‘ac/column/value’, ‘ac_column_value_acf_example_2’, 10, 3 );

2 years, 6 months ago
Stefan van den Dungen Gronovius
Developer

Correct, it is better to use our hook to change the value of our columns.
The other hook will probably also work if you’re using a higher priority (above 200) but since we created those columns, our hooks to change the value for columns is a better choice.

2 years, 6 months ago
Carlo Cannavò

I have tried also with priority in my old function and not work.
So using hooks is much better.

Now,
Since i have used hook to append calculated formula (only in display),
please see screenshot
Calculated Value Display

How can i export this value on Product List Export Reports?

Or maybe do you suggest something to have other columns for calculated formulas that also can i have in export file?

Thanks

2 years, 6 months ago

You must be logged in to reply to this topic.