Save Custom Fields for Variations Product

Okay, based on answers on link above (where I got the old code and there are people that help to answered), I put the modification code for my website. I tried it and it’s working like charm.

Change:

add_action( 'woocommerce_product_after_variable_attributes', 'variable_fields', 10, 2 );

Into :

add_action( 'woocommerce_variation_options', 'variable_fields', 10, 3 );

And change :

'value'       => $variation_data['_weightdesc'][0],

Into :

'value' => get_post_meta($variation->ID, '_weightdesc', true)

Leave a Comment