Home › Forums › Front-end Issues › ACF with Woocommerce
I am trying to use the ACF with woocommerce and original premium new theme , I want to show some more fields on the product page , I followed all steps in the plugin settings but still nothing appears on the product front end page , anyone can help me
is there any code I should add to my theme????
is there any video tutorial that can help?
Thanks elliot for your quick response but I tried to review it many times but still I cannot understand how it works :'( :'(
can you please give me a guide how to use the documentation at least , I am really confused
Hi @QueenEve
No worries.
1. Use ACF to create a field group containing the fields you want and then use location rules to match the post_type to the Woocomerce product
2. Research on the Woocomerce website to find out how you can customize the single product page
3. Edit that template and use the ACF functions such as get_field / the_field to display your custom field data
Hope that helps.
To better improve the docs, can you please provide some feedback? You say that you don’t know how to use the docs? How come?
Thanks
E
Hi,
I’m not sure how you went with this, but I am trying to add some ACF fields to the Single Products Page in Woocommerce. I was hoping to use the hooks that woocommerce provides to add the custom fields stuff, but I can’t seem to get the fields to output anything.
in my functions.php I have added an action like so:
// Add ACF Info to Product display page
add_action( 'woocommerce_after_single_product_summary', "ACF_product_content", 10 );
function ACF_product_content(){
echo '<h2> ACF Content </h2>';
if (function_exists('the_field')){
echo '<p>Woohoo, the_field function exists! </p>';
the_field('test_field');
}
}
The h2 and the p are displayed, but the field itself doesn’t get rendered. Any thoughts?
Cheers.
Hi @QueenEve
You can remove the if
statement surrounding the the_field function, ACF api will be available within this action.
It is most likely that ACF doesn’t haeva value for the field ‘test_field’, or ACF doesn’t know which post to load from.
You can do some testing like so:
<?php
echo '<pre>';
print_r(get_the_ID());
echo '</pre>';
echo '<pre>';
print_r(get_field('test_field'));
echo '</pre>';
die; ?>
Please report the output
Thanks
E
Hahaha I’m a total moron!
I had two test products called the same thing and I was testing the output on the wrong product… der π
Thanks for your help anyway π
a quick one, adding ‘die’ at the end of the debug stuff, what does that do exactly (and should I be adding that to all add_action functions in the future)?
For me, works only with:
<? echo get_field(‘name_of_field’) ?>
hey,
where did you put this function? I’m trying to show my custom fields on products single page too, with no luck.
I managed to get new fields on the backend, right under the Products name as I wanted, but now getting this to the front-end is a mystery to me.
Thanks Elliot,
finding a right solution around 2 weeks… thanks for your help
Hai Elliot,
I am trying to figure out how to use ACF with WooCommerce and add a few extra productfields to WooCommerce products and show them on a webshop / checkout / invoice etc. but unfortunately I am getting nowhere with ACF.
What really should help is a practical walkthrough tutorial in which a new product-field is added to the WooCommerce products like for example a country when selling bottles of wine on a WooCommerce webshop and also made possible to search / filter on the custom field and show it on various pages like the checkout, invoice etc…
I have googled several hours but somehow I cannot find the right guidence to help me with this. And yes, I am rather new to WooCommerce but am an experienced developer.
You state :
2. Research on the WooCommerce website to find out how you can customize the single product page
3. Edit that template and use the ACF functions such as get_field / the_field to display your custom field data
I have not researched in depth what this all means and where to find these ‘customizing the single product page’ info but I simply cannot believe that a simple and easy walkthrough tutorial of ACF in combination with WooCommerce is non-existend.
Hope anybody can help… Or direct me to a helpful plugin to add custom fields to a WooCommerce product…
Hi
I have added the ACF for schema structured data (on products in WooCommerce) but it does not show up in the structured data testing tool.
I have looked through the documentation and I canβt make head nor tail of it.
Any advice of what I need to get it to show up in the structured data testing tool
You better put this into a new post. This Thread is 7 Years old.
@Heavyside Hi there, would you mind helping me out solving the same issue? I have the free version of ACF..
The topic ‘ACF with Woocommerce’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.