I need help adding custom fields to my Product Variations and Simple Product pages. I tried using RemiCorson\'s info (http://www.remicorson.com/woocommerce-custom-fields-for-var
I have never needed to bother with woocommerce_product_after_variable_attributes_js
, you just need to add the input and then deal with saving it.
Another thing that has changed since Remi's article was published is that the WooCommerce variation meta data is no longer printed in a Here's is how you'd add a meta field to a variation:
element... and is now a
// regular variable products
add_action( 'woocommerce_product_after_variable_attributes', 'add_to_variations_metabox', 10, 3 );
add_action( 'woocommerce_save_product_variation', 'save_product_variation', 20, 2 );
/*
* Add new inputs to each variation
*
* @param string $loop
* @param array $variation_data
* @return print HTML
*/
function add_to_variations_metabox( $loop, $variation_data, $variation ){
$custom = get_post_meta( $variation->ID, '_custom', true ); ?>