Hi everyone,
The second and third headlines on this product archive page
https://dev.dr-kaffee.de/produkt-kategorie/kaffee/
should display the subcategories of UNSERE KAFFEES (SORTENREIN, MISCHUNGEN). Could you give me a hint on how to create the custom field for the page template? There will be more subcategory archive pages.
Best regards,
Anna
Hi all,
I am trying to make a ‘Vehicle Fitment’ field group for Woocommeece products using ACF pro repeater.
Inside the vehicle_fitment repeater I have 3 fields;
Vehicle_Make – taxonomy field for Product
Vehicle_Model – taxonomy field for Product
Vehicle_Years – select field containing years from 1995-2025
Each product may fit multiple different vehicles, hence why I’m using a repeater.
The only problem I’m having is then filtering on the front of the site when a customer chooses by Vehicle Make, Vehicle Model & Vehicle Year.
Could anyone suggest a better layout for this?
This is woocommerce product page, using product variations. Can I know if ACF is able to do this?
hello I create a taxonomy “brand” with acf plugin for woocommerce products
and now how can I show product brand in their page ?
Hello, i want to make ACF field display in admin-new-email template.
Hopping someone can help, i find this code, who displays my custom field in Cart page near price:
function order_review_custom_field($product_price , $cart_item, $cart_item_key){
$price= get_field('price_for', $cart_item['product_id']);
return ($price) ?
$product_price . '<div>/' . $price. '</div>'
:
$product_price . '<div> </div>';
}
add_filter('woocommerce_cart_item_price', 'order_review_custom_field', 999, 3);
And its shows really good. But now i want display it in email template, but now not near price, but near quantity. So its like PRODUCT NAME next column Quantity/(my custom field) And when Sub total. I hope you know what i mean.
Good morning
I’m looking for a little help here for a particular request…for which I can’t find a solution.
I’m looking to update a Select field when I change the value of a Relationship field.
My Relationship Field includes products from my WooCommerce and I only authorize a selection. (I didn’t do a loop)
My script for the select field works. In fact I would like to be able to launch the PHP update of this field from my JS
.on('DOMSubtreeModified', function()
But I do not know how…
Here is my complete script (JS and PHP) in my function.php file
function my_acf_input_admin_footer() {
?>
acf.add_action('ready', function( $el ){ // $el will be equivalent to $('body') // var $field = jQuery('.acf-field-65d324bb8637b');
jQuery('.acf-field-65d324bb8637b ul.values-list').on('DOMSubtreeModified', function(){ console.log('changed'); });
});
<?php } add_action('acf/input/admin_footer', 'my_acf_input_admin_footer'); // Fonction champ couleur function acf_load_product_variations( $field ) { // Reset du champ Select $field['choices'] = array(); // Récupération des infos "PRODUIT" $produit = get_field( 'produit'); // Si champ "PRODUIT" - UPDATE du
if($produit):
$product_id = $produit["0"]->ID;
$product = wc_get_product( $product_id );
$variation_ids = $product->get_children();
if ( $variation_ids ) :
foreach ( $variation_ids as &$variation ) :
$product = new WC_Product_Variation($variation);
$attributes = $product->get_attributes();
$data_array = array();
if( $attributes ){
foreach ( $attributes as $meta_key => $meta ) {
$display_key = wc_attribute_label( $meta_key, $product );
$display_value = $product->get_attribute($meta_key);
#$data_array[] = $display_key .' : '. $display_value;
$label = $display_value;
}
}
#echo implode( '
', $data_array ) . '
';
// Les variables
$value = $variation;
// $label = $produitName;
// Ajout au Select
$field['choices'][$value] = $label;
endforeach;
endif;
endif;
// Return the field
return $field;
}
add_filter('acf/load_field/name=color_product', 'acf_load_product_variations');
If anyone has an idea or has already encountered this problem, I’m interested!
Thanks for your help 🙂
I’m working on a website for a client that’s a complete redesign of their current site. When the new site goes live, I’ll need to keep everything I’ve done and merge in all of their current orders, comments, etc. from WooCommerce on the live site.
Is it feasible or what other way I can make merging process easier?
Hello. Please can someone show me how to add ACF fields in the subscription renewal orders?
(We need to add a tracking code for the subsequent deliveries).
Hello, I have made a field to add to the Woocommerce attributes. I have added a picture below for more clearancy.
I am trying to display the field on the single product page. I have added the following code to the content-single-product.php template file.
$terms = get_the_terms( $product->id, 'pa_merk');
var_dump($terms);
$image = get_field('afbeelding_merk', $terms->taxonomy . '_' . $terms->slug);
// Display the image if it exists
if ($image) {
echo '<img src="' . $image . '" />';
} else {
echo "<p>Foto niet gevonden.</p>";
}
What am I doing wrong?
Hello Guys:
I found a similar question to Link product to post (and vice versa) before ACF Relationship was released now still I have some questions about how to use it
1. I am using Elementor themebuilder single post template but the product(s) type is created by ACF, not woocommerce
2. then i have product(s) application post created by default WordPress POST
3. Now my question is how to display the post related to the product(s), which widget can I use, for example, I have the product(s) A, B, C, and D, and product(s) application posts a,b,c,d,e,f,g
and posts a,b,c,d was related to product(s) A, posts e,f,g was related to product(s) B
then below the product(s) A description section i want to have another section called related application post to show all the posts related to products A
is there a quick way can do it in the themebuilder single post template,
hope you can understand my questions
thanks
We use ACF plugin for woocommerce custom fields but can’t work on woodmart theme how to solve it?
Hello everyone!
I’ve used ACF on some projects, and now I need to create a true/false switch that allows me to display an image or a badge inside the WooCommerce product tab. I would like to show the badge below the description text. Could you help me with the code? Thank you.
Hello,
I’m using WP Bakery to build my site on WordPress. I’ve installed ACF and created a custom field called “coefficient,” which is a “number” ranging from 1 to 5. I’m using this field for my WooCommerce products.
I’m having trouble using the “coefficient” field to sort my products in my grids and carousels, While I can filter my products using this field, but sorting doesn’t seem to work.
Whether on grids or carousels with the “custom field” order and {{coefficient}}, it doesn’t function. I feel like it’s impossible to sort with an ACF field because I encounter the same issue with all these fields.
Can you assist me?
Hi,
I usually have a large number of repeater rows (80 – 100), each with several fields, used for my WooCommerce product, and this is substantially slowing down the administration product load times and also adding a new row takes a few seconds. I was trying to setup ajax loading for these fields, but couldn’t figure it out.
Would this be possible? What is the best way to optimalize loading speeds in admin?
Regards
Sadly WordPress doesn’t have a country list that can be accessed by various plugins in different scenarios. It does have a list of countries and cities in the time zone settings and WooCommerce installs its own country list available in setting up shops etc. Unfortunately a country list is not easily available in Advanced Custom Fields free or paid.
I found a free plugin on GitHub but it seems to either have a bug or is not yet ready for the 6.x series and it has no support. I also found a tutorial for making a country list plugin on Smashing Magazine (for 4.x) that led me eventually to an ACF example field type plugin template that should help me achieve my goal. However, it is so skimpy on instructions as to be useless to me not being a coder.
I followed all the instructions in the Readme and so far nothing shows in my available field types.
Can someone please take a look at the above-linked template and help guide me to getting a country dropdown list field.
I have a list with the codes and country names and also have it in a key/value pair array.
My two blockages are:
When I paste my 200+ line country list in a Select field type is works perfectly bu as I have three instances to select a country on one form, this means copy and pasting the list for each rather than just using an ACF Country Select Type.
Thanks.
Hi
I want to display other fields from.other tables. Woocommerce has a product page and i have added some custom fields. So far so good. I juts dont know how to display data from other tables
Is this possible? How please
Dear people,
I’ve quietly been struggling with the issue below for quite some time and have now decided to seek help through this forum.
I have created two taxonomies named “Model” and “Modeljaar” (Model Year). Additionally, I’ve set up an ACF field group linked to WooCommerce products.
Now, when specifying the compatibility of a WooCommerce product, I can choose both the “Model” and the “Model Year.”
However, if, for instance, I have 3 models – Volvo, Volkswagen, Audi – and model years such as “2015, 2016, 2017, 2018,” I encounter a problem.
For example, when I select Volvo and check model years 2015 and 2016, and also select Volkswagen and check model years 2017 and 2018, an issue arises.
The system fails to distinguish, assuming that Volkswagen is also linked to model years 2015 and 2016, as these model years are not linked to the “Model” taxonomy.
Ultimately, I need to create a search filter, such as with Search & Filter, and want to be able to search by model and model year. So, if you choose a Volkswagen now, you should also be able to find it when filling in the filter for model year 2015 or 2016.
I hope I’ve explained my problem clearly.
Do you have any ideas on how I can solve this?
Kind regards,
Miguel
Hi,
in recent days I had opened a request on the general forum of the repository regarding this question of mine.
I created some groups of fields in ACF that are shown in the sidebar, when inserting a product on woocommerce.
What I can’t do is show the fields in relation to the woocommerce categories.
Ex.
– woocat 1 -> group_1
– woocat 2 -> group_2In Position Rules I set the following rules:
1. Content Type = Product
2. User Role = Administrator
3. Item Taxonomy = woocat 1But despite this, the group of fields appears in every product page.
But having read the documentation for developers I created this function which should solve it and could possibly help other users too:
// Verifica se ACF è installato prima di utilizzare i filtri ACF
if (function_exists('acf')) {
add_filter('acf/load_field/name=attributo_montaggio', 'campoextra_acf_montaggio');
function campoextra_acf_montaggio( $field ) {
global $current_screen, $post;
// Verifica se l'utente corrente ha le autorizzazioni necessarie
if (!current_user_can('edit_posts')) {
// L'utente corrente non ha le autorizzazioni necessarie, esci
return $field;
}
// Ottieni i termini della categoria corrente
$terms = get_the_terms($post->ID, 'product_cat');
// Verifica se $terms è un array non vuoto
if (is_array($terms) && !empty($terms)) {
//$category_id = $terms[0]->term_id;
$category_name = $terms[0]->name;
// Array di nomi di categorie da confrontare
$allowed_categories = array(
"Cat Name 1",
"Cat Name 2",
// Aggiungi altri nomi di categorie secondo necessità
);
// Verifica se non siamo in modalità amministratore o se il tipo di post non è 'product' o se l'ID della categoria non è nell' array
if ((!is_admin() && $current_screen->post_type != 'product') || !in_array(strtolower($category_name), array_map('strtolower', $allowed_categories))) {
return false;
}
}
return $field;
}
}
I used the load filter and not the prepend.
Do you think it can be improved?
Thanks
I have been wanting to add video to my single product page gallery. I don’t know PHP so wasn’t able to do it myself, tried using chatgpt but to no avail.
https://dmmotionarts.com/product/diwali-festival-landing-page-elementor-template-free/
I tried adding ACF fields to images, with a oembed for images where I can add youtube videos. Is there a way to incorporate videos to product gallery?
I have tried using shoplentor plugin, in which it adds extra fields to images where we can add Youtube URL and then it replaces that image with youtube video. That way it allows to use video on any image in the gallery.
I have been trying to replicate it as it is lot more flexible and allows adding multiple videos at different locations in the gallery.
I’m working with WooCommerce and Advanced Custom Fields (ACF) in WordPress, and I’ve encountered a peculiar issue when trying to automatically update a custom field (order_shipping_number) in a WooCommerce order. I have two different methods for updating this field when an order’s status changes to “processing”, but only one of them works, and I’m trying to understand why.
Method 1: Direct Update (Not Working) I tried a straightforward approach where I hook directly into the woocommerce_order_status_processing action and update the field using ACF’s update_field function:
add_action( 'woocommerce_order_status_processing', 'update_product_custom_field_', 10, 1 );
function update_product_custom_field_( $order_id ) {
// Generate the shipping number using the order ID
$shipping_number = 'SHIPPINGNUMBERTEST';
// Update the custom field for the shipping number
if (function_exists('update_field')) {
update_field( 'order_shipping_number', $shipping_number, $order_id );
}
}
This method seems logical, but it doesn’t update the field in the WooCommerce order.
Method 2: Using acf/save_post (Working) However, when I use a nested action hook with acf/save_post, it works:
add_action( 'woocommerce_order_status_processing', 'update_product_custom_field_');
function update_product_custom_field_( $order_id ) {
add_action('acf/save_post', 'update_shipping_number');
}
function update_shipping_number( $order_id ) {
$shipping_number = 'SHIPPINGNUMBERTEST';
update_field( 'order_shipping_number', $shipping_number, $order_id );
}
With this method, the field updates as expected.
My Question: Why does the second method using acf/save_post work, but the direct approach fails to update the field? Is there something specific about how ACF handles data saving in the context of WooCommerce orders that requires the acf/save_post hook?
Any insights or explanations would be greatly appreciated, as I’m trying to understand the underlying mechanics of ACF and WooCommerce interactions.
We are using ACF Pro / Paid Plugin.
We have added a custom field on all our products – the field being the ‘File Upload’.
Can anyone assist with the following, or even, advise if this is something simply out of touch or better worded, just not possible
When the user uploads a file on product post #1 , example ‘image-1.jpg’ , this being the first instance they would be charged e.g. $1.00.
If the user decides to upload a file on another product post e.g. #2, if the filename is the same e.g. ‘image-1.jpg’ they will not be charged $1.00 as the image has been uploaded.
I understand this may cause issues in the event more than one user uploads a file with the same filename. So, secondly, is their a solution to this somehow to prevent a customer not being charged when they should be?
OR
Can we possibly do a unique count of files uploaded in one’s basket where the user has selected on products “file not uploaded before” and for each count charge $1.00
Example
Product 1 – user has selected logo uploaded before – ignore this file
product 2 – user has selected not uploaded logo before – filename1.jpg
product 3 – user has selected not uploaded logo before – filename1.jpg
product 4 – user has selected not uploaded logo before – filename2.jpg
Count = 2 (2 unique files uploaded) , charge = $2.00
Is it worth noting, customers are not enforced to be logged in (WooCommerce).
Our vision may not be the best way, and their maybe a better way to achieve the desired goal above.
Kind Regards,
the goal: add class to woocommerce single product template gallery thumbnails if media attachment ACF field toggled (true/false)
i have the following custom field (quick_ship):
i’ve added this in functions but not working at the moment:
<?php
$image = get_field('quick_ship');
$size = 'full'; // (thumbnail, medium, large, full or custom size)
if( $image ) {
echo wp_get_attachment_image( $image, $size, array ('class' => 'quick-ship' ) );
}
thanks for any help.
Hi I have a website with woocommerce in Avada with ACF pro.
I have 3 custom fields set up and added to woocommerce products, these fields show in the add/edit products page, and show on the woocommerce product page. This part is working perfectly.
I have a form set up which posts the query using the method GET to /?s=
in the form is a hidden field with the value post_type=product
in the form is a drop down menu withe the value product_cat in the Field Name and a list of the category names and slugs in the options menu.
So far this part works fine, I can search for anything, and refine the search by product category.
The part I need help with is include the ACF custom fields in the form to refine the search further.
What values should I use for the three ACF custom fields?
For example the first custom field set up in ACF is a Post Type called Authors (the plural label is Authors, the singular label is Authors, and the Post type key is authorname, under taxonomies is Product Visibility)
Under the main Taxonomies tax on the left there is nothing.
How do I go about adding this Post Type as another refining factor in the search form.
I can add a text field but what should I set as the Field Name?
So after googling for a few hours I can’t find the solution yet.
I took over a website for an animal shelter. They used Woocommerce to display animals that are up for adoption as products. But because the animals can’t be directly adopted the whole cart/checkout is not used.
I love the idea of using ACF. But all the topics I found is about adding ACF fields into Woocommerce.
I wanna use ACF fields and to slowly but steady build the website in parts show some Woocommerce fields to start with it. Because animals are added, removed, updated daily. And this doesn’t seem like a project done in an evening.
// FIELDS THAT ARE USED FOR EXAMPLE
– Featured image
– Product title
– description
– category
– pa_attributes
What is the best way to achieve this?
1. I would love this way to start with but I can’t find a way to convert/import/show the woocommerce products in to ACF fields.
2. Start all over, make new fields for the animal. Figuring a way out how to convert the woocommerce fields into the ACF fields while the volunteers can still update/add animals.
3. Other….explain please
Hi everyone,
Please help me. I use ACF image field to set banner for each category product woocommerce, but i can’t get this to front end, my code is
<?php if( get_field('banner-category') ): ?>
" />
<?php endif; ?>