Hi to all.
I have created a text custom field in woocommerce category products.
What should I do to display the custom field content in single product page?
Thanks
Open up the /plugins/woocommerce/templates dir. In there you’ll find content-single-product.php. In there you’ll find Woo actions being called and above each a list of hooks that the action contains. Find the hook that describes the area you want to add your custom fields to, for example woocommerce_template_single_excerpt. Then you Google that hook and on the docs.woothemes.com result you can click the link to ‘Located at’ file. On that page you search for woocommerce_template_single_excerpt. The function you arrive at will tell you the file used is single-product/short-description.php. Now you don’t want to modify this file directly, just like you don’t want to modify the WP core. Instead you copy plugins/woocommerce/templates/single-product/short-description.php to themes/YOURTHEME/woocommerce/single-product/short-description.php. Then you edit that file.
I’m still working on my first WooCommerce website so I don’t know if this is the fastest way to find the template part you need but this is how I’m doing it.
Hi, I have solved this problem adding this code in functions.php:
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_top_category_desc', 1 );
function woocommerce_template_top_category_desc (){
$terms = get_the_terms( $post->ID, 'wc-attibute-class' );
if ( !empty($terms)) {
$term = array_pop($terms);
$text= get_field('txt-field', $term);
if (!empty($text)) {
echo $text;
}
}
}
`Hi, I’ve able to achieve this in a new tab in woo commerce single product page by using below code
function woo_products_tabs ( $tabs ){
$tabs[‘your_tab_name’] = Array
(
‘title’ => “Tab_title”,
‘priority’ => 15,
‘callback’ => ‘your_tab_name’
);
return $tabs;
}
function your_tab_name(){
echo “<h2>Tab_title</h2>”;
$var=get_field(‘acf_field_name’);
echo “<p> $var </p>”; // out put the datafield
}
i didnt create any child theme for theme
i need the location wer i gonna edit the code for the custom fields in product
i didnt create any child theme for theme
i need the location wer i gonna edit the code for the custom fields in product