Reputation: 389
As it said in the title I'm trying to retrieve the data from my ACF's fields.
Better than an explanation, please see the following screenshot:
So as you can see I've created under my attribute 'pa_size' the 2 following text fields: uk-size and us-size.
Which is giving the following result in my Products->attributes backend:
Until there, everything's ok but the next step is to retrieve these data to the following single-product (variable) screen:
I tried with this documentation from ACF to do it but impossible. I also tried to place different part of code under /public_html/wp-content/themes/atelier-child/woocommerce/single-product/add-to-cart/variable.php but no way to figure it out. It's been days I am struggling on it and it's driving me super crazy.
I would like if I click on "UK" or "US" to display sizes like on this link.
If anyone could help even just a little bit, I would be really grateful!!
Thanks in advance guys.
Upvotes: 0
Views: 333
Reputation: 3399
Could you provide the code that you tried?
All of the objects that are not a post type use a special "post id syntax": https://www.advancedcustomfields.com/resources/get-values-from-a-taxonomy-term/
In your example you have the taxonomy pa_size, and let's pretend the term you are editing is number 352.
$term_id = 352;
$us_size = get_field( 'us_size', 'pa_size_' . $term_id, );
$uk_size = get_field( 'uk_size', 'pa_size_' . $term_id, );
Is this what you are looking for? Or are you wondering about tying it in to toggle the values of the dropdown menu?
Upvotes: 1