php – Display custom field value in woocommerce variable product via jQurey

Question

I try to display the custom value fields that each variation has.

I use this code to display variation id and variation description:

add_action( 'woocommerce_before_single_variation',
 'action_wc_before_single_variation' );
function action_wc_before_single_variation() {
    ?>
    <script type="text/javascript">
    (function($){
        $('form.variations_form').on('show_variation', function(event, data){
            console.log( data.variation_id );      // The variation Id  <===  <===
            console.log( data.variation_description );        // The variation description  <===  <===

        });
    })(jQuery);
    </script>
    <?php
}

Now I want to show these fields from the picture in the same function.

Metadata fields

Is that possible?

0
MrBrabus 2 weeks 2021-10-08T12:24:24-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse