We just had the same problem with a transition from ACF+Repeater, etc., to Pro. All our field groups but one were duplicated. The one that was not duplicated had only a single text field; each of the others had repeater, WYSIWYG and/or related post link fields.
The bad news is that in at least one case, there are two fields missing from one of the repeater fields in the older version of the field group. The portal_box field in field_group #5209 has only three fields; the one in field_group #5255 contains all five of the fields that should be there. (See attachments.) As a result, part of the portal box is not displaying.
We have no multi-language support. Here’s a list of our active plugins:
ManageWP – Worker (v4.1.6) by ManageWP
Gravity Forms (v1.9.9) by rocketgenius
Admin Quick Jump (v1.4) by James Kemp
Advanced Custom Fields Pro (v5.2.6) by elliot condon
Advanced Post Types Order (v3.6.2) by Nsp Code
BackWPup (v3.1.4) by Inpsyde GmbH
Categories Images (v2.5) by Muhammad Said El Zahlan
Cookies for Comments (v0.5.5) by Donncha O Caoimh
Duplicate Post (v2.6) by Enrico Battocchi
WordPress Editorial Calendar (v3.5) by Colin Vernon, Justin Evans, Joachim Kudish, Mary Vogt, and Zack Grossbart
Enable Media Replace (v3.0.3) by Måns Jonasson
Google Analytics by Yoast (v5.4.2) by Team Yoast
Google Calendar Events (v0.7.2) by Ross Hanney
Gravity Forms – Placeholders add-on (v1.2.1) by Joan Piedra
Gravity Forms MailChimp Add-On (v3.6) by rocketgenius
Image Watermark (v1.5.0) by dFactory
McWebby Magnific Popup (v00.01.00) by Donna McMaster
McWebby Custom Post Types (v00.02.01) by Donna McMaster (declares post types)
Media Tags (v3.2.0.2) by Paul Menard
Members (v0.2.4) by Justin Tadlock
Simple Sitemap (v1.65) by David Gwyer
Sucuri Security – Auditing, Malware Scanner and Hardening (v1.7.9) by Sucuri, INC
Category Order and Taxonomy Terms Order (v1.4.2) by Nsp-Code
ThreeWP Activity Monitor (v2.12) by edward mindreantre
WooCommerce Bulk Discount (v2.3.1) by Rene Puchinger
WooCommerce Dynamic Pricing (v2.9.6) by Lucas Stark
WooCommerce (v2.3.10) by WooThemes
WooThemes Helper (v1.5.5) by WooThemes
WordPress SEO (v2.1.1) by Team Yoast
WP Migrate DB Pro (v1.4.7) by Delicious Brains
WP SEO Humility (v0.1) by Donna McMaster
Must-use Plugins:
ManageWP – Worker Loader (v) by ManageWP
McWebby Debug Log (v0.1.0) by Donna McMaster
If I understand correctly, what you want to do is to show the woocommerce fields in the ACF field group when it is show on a post or page and to run PHP code.
I would probably use this add on plugin: https://wordpress.org/plugins/acf-enhanced-message-field/
Hi @marion2318
You can use the location rules to map a certain field group to a specific product. This can be found under ‘post’ => ‘specific post name’
You can also refer to this thread for code examples: http://support.advancedcustomfields.com/forums/topic/relating-posts-with-woocommerce-products/
Hi,
Here is an almost similar thread on how to access acf field from the product category page.
I hope this helps.
But wait, how to remove from add product page (WooCommerce)?
Thanks…
Hi, thanks for response.
I have this
And i need add new pair of fields each time a new category is added.
This categories are added by a external software using the woocommerce API.
Hi @maidus
Hmm… You could have the page_link field type as a sub field for the repeater field. Then on the page_link option, you filter the posts by the post type for woocommerce product.
How would you add a standard custom field to the order page in WooCommerce? You would basically do the same thing. Use the ACF field name as the name of the custom field. Only hitch might be if it is a field like a multiple select, checkbox or maybe a repeater.
How would you set a standard custom field’s value in a plugin action? Again, basically the same with ACF except that you also need to set a special custom field to tell ACF how the value is used. The special custom field name is equal to '_'.$field_name
and the value of this field is the ACF field key.
I sent a support ticket and got a reply about 12 hours ago. They said: “Sorry for the inconvenience, our team is working to restore the site, the service will be back on in a short while.”
I know there are sometimes issues with WooCommerce – which is what they are using for their shopping cart. It usually has to do with plugin conflicts, or sometimes server compatibility (if they recently moved their site). Hopefully it’s not a conflict between ACF and WooCommerce! 😉
There is a fix that sometimes works (hope support is reading this…) that you simply go to the WooCommerce settings and click the Clear all sessions button and the Clear Transients button…
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;
}
}
}
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.
OK, I’ve come to this problem from another angle and did resolve that part like this:
// =============================
// frontend single ifcc logic
// =============================
function cpt_front() {
global $post;
// this here is for making sure not to fall in redirect loop trick :)
if( $post->ID == get_option('woocommerce_myaccount_page_id') ){
return;
}
if ( $post->ID == 53 && !is_admin() ) {
if( is_user_logged_in() ){
acf_form_head();
add_action( 'the_content', 'callsall' );
} else {
wp_redirect( get_permalink( get_option('woocommerce_myaccount_page_id') ) );
exit();
}
}
}
add_action( 'template_redirect' , 'cpt_front' );
this is only thing in my plugin to get handle on my cpt here, not from template file..
the only ugly thing here is hardcoded postID inside,, but that would need to be saved in some variable and read..
thanks
Sure,
I call this in my custom plugin..
/* acf post generate */
function create_acf_post( $post_id )
{
// check if this is to be a new post
if( $post_id != 'new' )
{
return $post_id;
}
// Create a new post
$mytitle = get_user_meta( get_current_user_id(), 'nickname', true ) . ' - ' . $_POST['fields']['field_547959d79b64c'];
$post = array(
'post_status' => 'draft' ,
'post_title' => $mytitle,
'post_type' => 'ifcc'
);
// insert the post
$post_id = wp_insert_post( $post );
// update $_POST['return']
$_POST['return'] = add_query_arg( array('post_id' => $post_id), $_POST['return'] );
$user_id = get_current_user_id();
update_user_meta( $user_id, 'done_free', '1' );
// wp_redirect('/');
// return the new ID
return $post_id;
}
add_filter('acf/pre_save_post' , 'create_acf_post' );
and that is fired on frontend while after couple of pars are meet,, frontend, is single, is custom post (ifcc) and logged in..
// =============================
// frontend single ifcc logic
// =============================
function cpt_front($query) {
if ( !is_admin() && $query->is_main_query() ) {
if ($query->is_single() && $query->post_type == 'ifcc' ) {
if( is_user_logged_in() ){
$user_id = get_current_user_id();
$usernick = get_user_meta( $user_id, 'nickname', true );
update_field('submitee_name', $usernick);
$free = get_user_meta( $user_id, 'done_free', true );
if( $free == '1' ){
echo 'need to buy additional licence';
} else {
get_template_part( 'content', get_post_format() );
$args = array(
'post_id' => 'new',
'field_groups' => array( 68 )
);
acf_form( $args );
}
} else {
// echo get_permalink( get_option('woocommerce_myaccount_page_id') );
echo do_shortcode('[woocommerce_my_account]');
}
}
}
}
add_action('pre_get_posts','cpt_front');
so, everything works cool, and post is inserted in backend and all, but redirect part if off somehow,,
thanks
I tried your code with a little bit changes and it’s working,
I think you have missed 'field_groups' => array(YOUR_FIELD_GROUP_ID),
in your acf_form() , Try adding the id of your field group to the acf_form()
<?php
function woocommerce_variation_options_acf_form($loop, $variation_data, $variation) {
add_action('admin_head','acf_form_head',20);
$variation_id = $variation->ID;
?>
<tr><td colspan="2">
<style>
table.data_table td #poststuff { padding: 0; min-width: 1em;}
table.data_table td .postbox { min-width: 1em;}
table.data_table td div.acf_postbox div.field_type-true_false p.label { display: inline; }
table.data_table td div.acf_postbox div.field_type-true_false ul {display: inline-block;}
#variable_product_options .woocommerce_variation table td input[type='checkbox'] { min-width: 1em!important;}
</style>
<?php
acf_form(array(
'post_id' => $variation_id,
'form' => false,
'label_placement' => 'top',
'instruction_placement' => 'label',
'field_groups' => array(28),
'return' => add_query_arg( array( 'post_id' => $post_id, 'updated' => 'true'), get_permalink() ),
));
// var_dump( $variation_id );
?>
<script type="text/javascript">
(function($) {
// setup fields
acf.do_action('append', $('#popup-id'));
})(jQuery);
</script>
</td></tr>
<?php
}
add_action('admin_head','acf_form_head',20);
add_action('woocommerce_product_after_variable_attributes','woocommerce_variation_options_acf_form',99);
/**
In WooCommerce : includes/admin/meta-boxes/views/html-variation-admin.php
*/
do_action( 'woocommerce_product_after_variable_attributes', $loop, $variation_data, $variation ); ?>
try this and use your own field group id instead of ’28’ in 'field_groups' => array(28)
The error that wilirius posted said it is timing out, also that WooCommerce works fine using the same function.
ACF does not set a value for timeout so it will use the defualt.
The default value for timeout use by WP is 5
The timeout used by WooCommerce for wp_remote_get() is 60
$response = wp_remote_get( $this->get_language_package_uri(), array( 'sslverify' => false, 'timeout' => 60 ) );
So, that’s is a difference.
Try adding a timeout arg to the call in ACF of 60?
I have tried WordPress Ultimate CSV Importer Pro from Smack Coders. It didn’t work for me and I cot tired of back and forthing with their support. My problem was that the site in question used “product” as a post type and “product-type” as a taxonomy. Their plugin assumed the presence of these things meant I was using WooCommerce, even when I did not check the WooCommerce box and checked the ACF box.
I also tried it on other sites that use ACF. ACF support in this plugin is poor and spotty. The other problem I have with it is the fact that the code is obfuscated with IonCube and they always use the latest version, it is difficult to use if your host is not on the latest version or they change versions because it seems that IonCube is almost never backward compatible.
Overall, my experience with the plugin was poor and my experience with their support was poor. I personally will never attempt to use it again.
Everything I build in WP is done with ACF and I doubt that we’ll have a csv importer to work with ACF until someone takes the time to build one that focuses on how ACF stores data.
I been using ACF and WPML and Woocommerce for a long time with very complex ACF and language setup. I Just installed the ACF PRO and this become Changed:
The “Duplicate” of a ACF is no longer dublicated, it creates a translated independent copy of the original language field setup. Before you could see the WPML box “Make xxx fieldgroup independent” (WPML will no longer sync…)
Today, if we add changes in the Field group, we must add the “new” fields in that fieldgroup, values, etc etc manually for EACH translated field group. Not fun when using 10 languages.
On the other hand, To make headlines, titles translated, the field group MUST released as a “duplicate” and become independent. (As before)
We always keep the fieldgroups as “dublicated” (But now ACF cant do it) as long as possible, and when all testing and the client is happy, we release all translations and finally, translate the labels and titles.
ALSO:
REF Elliots article “Multilingual Custom Fields”
in WPML “Mulitilingual setup — Custom fields translation”, These properties (Custom fields) has to be checked as “Copy from original to translation”:
-allorany
-field_1
-hide_on_screen
-layout
-position
-rule
Then, everything works fine for us, as for many installs, last 3 years, update after update WPML + ACF.
on a production website, running in older versions (WordPress 3.9.2 // Advanced Custom Fields by Elliot Condon version 4.3.8 // WPML Multilingual CMS by ICanLocalize version 3.1.6 // WPML Translation Management by ICanLocalize version 1.9.5), everything works fine:
### Environment ###
WC Version: 2.1.12
WC Database Version: 2.1.12
WP Version: 3.9.2
WP Multisite Enabled: No
Web Server Info: nginx/1.1.19
PHP Version: 5.3.10-1ubuntu3.13
MySQL Version: 5.5.35
WP Memory Limit: 256 MB
WP Debug Mode: No
WP Language: Default
WP Max Upload Size: 32 MB
PHP Post Max Size: 32 MB
PHP Time Limit: 300
PHP Max Input Vars: 1000
SUHOSIN Installed: No
WC Logging: Log directory is writable.
Default Timezone: Default timezone is UTC
fsockopen/cURL: Your server has fsockopen and cURL enabled.
SOAP Client: Your server has the SOAP Client class enabled.
WP Remote Post: wp_remote_post() was successful – PayPal IPN is working.### Plugins ###
Installed Plugins: Advanced Custom Fields: Date and Time Picker by Per Soderlind version 2.0.16
Advanced Custom Fields: Repeater Field by Elliot Condon version 1.1.1
Share Buttons by AddToAny by AddToAny version 1.3.5
Adminimize by Frank Bültge version 1.8.4
Advanced Custom Fields: Limiter by Atomic Smash – David Darke version 1.1.0
Advanced Custom Fields by Elliot Condon version 4.3.8
Akismet by Automattic version 3.0.2
Contact Form 7 by Takayuki Miyoshi version 3.9.1
Custom Favicon by Dreams Online Themes version 1.0.2
Google Analytics for WordPress by Joost de Valk version 4.3.5
Google XML Sitemaps by Arne Brachhold version 4.0.7
Latest Custom Post Type Updates by David Wood version 1.3.0
Simple Image Sizes by Rahe version 3.0
WPML Multilingual CMS by ICanLocalize version 3.1.6
Soliloquy Thumbnails Addon by Thomas Griffin version 1.0.4.1
Soliloquy by Thomas Griffin version 2.3.4
User Role Editor by Vladimir Garagulya version 4.14.4
WooCommerce Gateways Country Limiter by OnTheGoSystems version 1.0.3
Woocommerce Adwords Conversion Tracking by Víctor Falcón version 1.0.1
WooCommerce MailChimp by Adam Anderly version 1.3.1
WooCommerce Multilingual by ICanLocalize version 3.3.2
WooCommerce by WooThemes version 2.1.12
WooCommerce HeidelpayCw by customweb GmbH version 1.0.120
wpMandrill by Mandrill version 1.33
WPML CMS Nav by ICanLocalize version 1.4.4
WPML Media by ICanLocalize version 2.1.5
WPML Sticky Links by ICanLocalize version 1.3.4
WPML String Translation by ICanLocalize version 2.0.6
WPML Translation Management by ICanLocalize version 1.9.5
Same problem too —
This was solved in WooCommerce update 2.2.6 (released a day later) so it looks like a problem with their plugin rather than ACF.
We have the same problem after updating to woocommerce Version 2.2.5, advanced custom fields no longer save when “Update” is clicked, the fields remain blank.
The first Woocommerce issue was likely unrelated to ACF Pro.
The latter two popped up because acf_form_post::save_post()
hooks onto ‘save_post’. This hook only fires if something changs on the post’s <i>main</i> fields. What this means, for example, if you change a field within an ACF metabox without changing anything else, this hook doesn’t fire. Instead, hook into ‘pre_update_post’. See this diff to solve this problem:
http://pastie.org/9617141
Here is a reference to this same problem in another plugin.
Tried using the acf_form()
function inside a function hooking to the 'woocommerce_product_options_general_product_data'
action.
While it renders the entire form (including the “update” button), the fields don’t save.
Tried it both with and without calling the acf_form_head()
function beforehand (which I wouldn’t think would be necessary anyway). Tried both submitting the form by clicking the product’s “update” submit button and the “update” button rendered within the form itself.
I have been looking for that answer too. Since WooCommerce is such a huge WordPress plugin, I would think there would have to be some kind of integration possible. Anyone?
Champion! That fixed the issue! Thanks! Sorry for all the replies – we got there eventually! If there are any further issues I will post entire code blocks next time!
One quick question, is your advancedcustomfields.com/my-account/ a custom built area? Is it woocommerce with a custom theme?
Thanks again.
Both tests confirmed it was returning the term ID. The first returned 16 and the second returned:
stdClass Object ( [term_id] => 16 [name] => Clothing [slug] => clothing [term_group] => 0 [term_taxonomy_id] => 16 [taxonomy] => product_cat [description] => [parent] => 0 [count] => 12 [filter] => raw )
As for woocommerce support on this particular subject, there isn’t much out there at all, and what I’ve found didn’t work. At the start, it seemed like something I could track down because adding a custom WYSIWYG field above the main woocommerce product loop would allow for a simple way to customize the page content for each product category… but nothing. I even posted the same issue on WooCommerce’s support site and still nothing after 3 days. So strange.
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.