Combining woocommerce and acf

HI
i have created field groups and field names, and assigned values to them on the woo product page (give the location allowed; see here).
Now I wish to pull text that gives me the assigned value for a specific product, using something akin to a shortcode.
I am not sure how to pass variables to the {{acf:field_name}} in order to display according to woo’s product ID.
Can you please show me for example how to display the part number. Details in a private note.
Thank you

Hello @flashfog,

Thanks for writing in!

First thing, please change your field name from “part_#” to part_number or part_num. As much as possible, kindly refrain from using any characters on the field names. The only accepted in the naming conventions is the underscore character.

And then, you may use this: {{dc:acf:field field="part_number"}. For more information about the Dynamic Content, ACF Pro, and how you can use this, kindly check this out:

Hope this helps.

Hi
I updated the filed name as instructed and generated this string

{{dc:acf:field field=“part_number”}

it is however simply showing that same text. The question of how to link the wish of showing a part number to a specific product, based on it’s product ID is still outstanding.

Details in private note

THANKS

Hello @flashfog,

Before anything else, since you have changes the field name, you will have to edit each posts and update the part number. I went ahead and edited part number of the test product.

And then on the test page, I added this instead: {{dc:post:meta post="15054" key="part_number"}}. We need to supply the product ID. If you notice, the dynamic content code is using post instead of product. You must always supply a product ID so that it can extract the field value of which product post.

Kindly check out your test page now.

Ok, What I am understanding here is that that the first suggestion:

Does not really work, and so we need to go via the WP generic method, i.e. custom meta.

Is this due to ACF not being able to do this, or just a way to avoid having to deal with ACF?

Thanks a lot, I do think this unlocks all the fields to be used as text when needed.

Hello @flashfog,

The {{dc:acf:field field="part_number"} usually works for posts. In your case, it is different because you are trying to display fields on a normal page of a specific product and this is why we go back to using the custom meta.

Best Regards.

ok, thank you again

Hi @flashfog,

You’re welcome and it’s our pleasure to help you. If you have any other concerns, feel free to reach us.

Thank you.

Just to let you know I have been able to use ACF’s short code functionality, in places where {{dc:post:meta post=“15054” key=“part_number”}} was not being evaluated.

for example [acf field=“part_number” post_id=“15960”] works successfully.

I followed this guide.

I hope this will help other people.

Hello @flashfog,

Thanks for sharing the information I am sure it would help other people.

Have a great day!
Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.