Yes, I did test with update_field()
using field key – same outcome.
BTW, in both cases
get_field( 'speakers', $post_id );
returns
Array ( [0] => 1 [1] => 101 )
Not only when product tag is changed (ajax returns empty array), also when product category is changed (ajax returns empty array), or product type is changed (no actions at all).
I did experiment:
– fresh install, latest versions of components – WP 4.7.5, Woocommerce 3.0.7 and ACF 5.5.14;
– extremely minimal theme, with empty index.php, empty style.css, and function.php file with content for creating custom product type:
// initial actions
function custom_init() {
// add custom product type term
add_custom_product_type_term();
// custom product type class
class WC_Product_Test extends WC_Product {
public function __construct($product) {
$this->product_type = 'test';
parent::__construct($product);
}
}
}
add_action('init', 'custom_init');
// add custom product type to product type selector
function custom_product_type_selector ($types) {
$types['test'] = 'Test';
return $types;
}
add_filter('product_type_selector', 'custom_product_type_selector');
// add custom product type term
function add_custom_product_type_term() {
$product_types_existing = get_terms(array(
'taxonomy' => 'product_type'
,'hide_empty' => false
));
$exists = false;
foreach ($product_types_existing as $pte)
if ($pte->slug == 'test')
$exists = true;
if (!$exists)
wp_insert_term('test', 'product_type');
}
– two product categories (‘Category 1’ and ‘Category 2’) and two tags (‘Tag 1’ and ‘Tag 2’);
– field group created, for post type ‘product’ with product_type ‘test’;
– field group created, for post type ‘product’ with tag ‘Tag 1’;
I run same actions:
1. Creating / editing product: on product type ‘Test’ select / deselect, corresponding acf group doesn’t appears / disappears.
No PHP errors logged. Console shows nothing.
2. Creating / editing product: on adding / removing tag ‘Tag1’, corresponding acf group doesn’t appears / disappears.
No PHP errors logged. Console shows nothing.
3. Editing product with type ‘test’, acf group is visible. Selecting / deselecting product categories causes acf group disappearing.
Initial state – both categories are selected.
After one category deselected, ajax fires with form data:
post_id:668
post_taxonomy[]:
post_taxonomy[]:15
action:acf/post/get_field_groups
exists[]:group_593352f539930
exists[]:group_58a595ba1534b
nonce:55b5acd041
Response:
{"success":true,"data":[]}
After one category selected, ajax fires with form data:
post_id:668
post_taxonomy[]:
post_taxonomy[]:15
post_taxonomy[]:16
action:acf/post/get_field_groups
nonce:55b5acd041
Response:
{"success":true,"data":[]}
After other category deselected, ajax fires with form data:
post_id:668
post_taxonomy[]:
post_taxonomy[]:16
action:acf/post/get_field_groups
nonce:55b5acd041
Response:
{"success":true,"data":[]}
Disappearing of acf groups, when adding / removing product image, or adding / removing tag – such behavior is not observed yet.
So for the moment the biggest issue still exists, and it seems, that ajax call with action ‘acf/post/get_field_groups’ causes the problem. Am I right?
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.