I am trying to create a custom field in the product attributes in Woocommerce. This to be able to select if an attribute is highlighted or not. For example:
@Jesús Magallón's
Answer need little modifications.
Remove the function get_attribute_highlighted()
and replace this line
$value = get_attribute_highlighted($attribute->get_name(), $i);
TO
global $post;
$post_id = isset($_POST['post_id']) ? absint($_POST['post_id']) : $post->ID ;
$value = get_post_meta($post_id , "attribute_description".$i, true);
It will show ajax saved value instance of empty;
And Change hooks
add_action('wp_ajax_woocommerce_save_attributes', 'wcb_ajax_woocommerce_save_attributes', 10);
TO
add_action('wp_ajax_woocommerce_save_attributes', 'wcb_ajax_woocommerce_save_attributes', 0);