How are product fields loaded to order WooCommerce?

92 views Asked by At

There is a lot of interesting articles about How are checkout fields loaded to WooCommerce but I need to add custom fields on product pages and then add variable values to checkout page and order.

Could I add this fields like in default post type?

If ORDER is custom post type called order_post it is possible but how...

HUGE thank you!

1

There are 1 answers

1
AudioBubble On

try to add the bellow code to your theme function.php

add_action( 'woocommerce_after_single_product_summary', 'add_custom_field', 0 );

function add_custom_field() {
global $post;
echo "<div class='prod-code'>Product Code: ";
echo get_post_meta( $post->ID, 'Product Code', true );
echo "</div>";
return true;
}

and in your style.css add below code

.prod-code {
position: absolute;
margin-top: -23px;
right: 20%;
}

If it work please confirm !