I am working on a project in woocommerce.
Can anyone help me to add a custom text field next to “add to cart”?
I tried the following but it is not working.
add_action( 'woocommerce_after_single_product_summary', 'add_custom_field', 0 );
function add_custom_field() {
global $post;
echo "<div class='prod-code'>Product Code: ";
$text= get_field('txt-field', $post);
echo "</div>";
return true;
}
Perhaps try using
$post->ID
like this:put your html code inside content-product.php (wp-content/themes/YOUR THEME/woocommerce/content-product.php)
content-product.php contains code of list page in wordpress. if you want to edit product page than edit content-single-product.php.
You are using Woocommerce there are two case :
You can implement it via single function :