Support

Account

Home Forums ACF PRO ACF display issues

Solving

ACF display issues

  • Hello,

    First of all, thank you for your wonderful plugin. Life is easier now ,)

    I’m facing some ACF bugs. Especially unpleasant and dangerous is third issue. As a developer, I can handle situation, but when it comes to my clients, it’s getting dangerous to lose data.

    WP 4.7.5
    ACF PRO 5.5.11
    Woocommerce 2.6.14

    – Issue 1 – lowest priority:

    I’ve created custom field group for products, that have particular tag:
    https://www.dropbox.com/s/12zp8oyq8b46g54/tags.png?dl=0
    In add / edit mode, if tag is added / removed – corresponding field group doesn’t shows / hides.
    Nothing happens, until product is not saved.

    – Issue 2 – medium priority:

    I’ve created custom field group for products, with custom product type:
    https://www.dropbox.com/s/awdt1zzvbfqdewr/product_type_01.png?dl=0
    In add / edit mode, if product type is changed – corresponding field group doesn’t shows / hides:
    https://www.dropbox.com/s/xu5jp7k4nl1zhap/product_type_02.png?dl=0
    Nothing happens, until product is saved. Then corresponding field group appears / hides.

    – Issue 3 – highest priority:

    Sometimes, after certain actions, but randomly (not every time), ACF fields display breaks down:
    https://www.dropbox.com/s/ycibzkj6ynf98ty/acf_display_bug.png?dl=0

    Scenarios to reproduce bug:

    * Product already created, has custom product type, ACF fields filled. Product in edit mode. After product category select / change – ACF display bug occurs.

    * Product already created, has custom product type, ACF fields filled. Product in edit mode. After paroduct tag add / remove – ACF display bug occurs.

    * Product already created, has custom product type, ACF fields filled. Product image is set. Product in edit mode. After product image remove – ACF display bug occurs.

    Maybe there are more scenarios to break ACF display, but that three is most common.

    How can I avoid such a situations?

    Greetings,
    Justinas

  • All of these cases, where the ACF field groups do not show or for some reason the field groups do not change as expected probably have the same root cause.

    When the page loads ACF determines what fields to display, this is the case when you need to save a page to make the field groups appear as expected.

    After a page is loaded, immediately on some pages and also when something that should trigger ACF to update the field groups, ACF does an AJAX request to check on what field groups should be shown. If anything goes wrong with this request then what happens is nothing. This is what I suspect is causing all of your issues.

    First, check for JavaScript errors in console. If there are any, try to clear them up. Second, turn on debugging and logging https://codex.wordpress.org/WP_DEBUG and check your log to see if there are any PHP errors that could be causing the AJAX request to fail.

    You can also try deactivating other plugins and/or switching themes to help narrow down what could be causing the issues.

  • 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?

  • I just did some testing without adding anything but WC to a test site. I can confirm that there does seem to be some kind of an issue with the field groups not updating correctly when a product tag is changed. Please submit a new support ticket here https://support.advancedcustomfields.com/new-ticket/

  • 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).

  • This reply has been marked as private.
  • This reply has been marked as private.
  • Hola,

    We are still experiencing this issue. Does anyone have an update?

    Kinds regards,

    Niels

  • Hey all,

    Is there any movement in this issue? Because I’m running into this also.
    An update on the progress would be very much appreciated.

    Kind regards,
    Rian Rietveld

  • Same issue, help appreciated, thanks!

Viewing 10 posts - 1 through 10 (of 10 total)

The topic ‘ACF display issues’ is closed to new replies.