• Resolved soroka95

    (@soroka95)


    Hi! I have a function in functions.php which cause an error in Site Kit Summary:
    Data error in Analytics – The server provided an invalid response.
    Screenshot: https://prnt.sc/tTBVFFdjJ71s

    Function has is_admin() check, so I don’t understand how can it cause a problem with Site Kit Summary , please help me, thx.

    Function:

    //==============================================================================
    //	Disable payment gateway "Cash on delivery" if there's specific ACF product in cart
    //==============================================================================
    add_filter('woocommerce_available_payment_gateways', 'filter_gateways_byacf');
    
    function filter_gateways_byacf($gateways) {
    	// Make sure it's only on front end
        if ( ! is_admin() ) {
    		
    		// Check if WooCommerce is active
    		if (!function_exists('WC')) {
    			return $gateways;
    		}
    
    		// Get the current cart
    		$cart = WC()->cart;
    
    		// Loop through cart items
    		foreach ($cart->get_cart() as $cart_item) {
    			// Get the product ID
    			$product_id = $cart_item['product_id'];
    
    			// Get the supplier value for the product
    			$supplier = get_field('supplier', $product_id);
    
    			// Unset "cod" gateway if supplier is "Brain"
    			if ($supplier != 'Brain') {
    				unset($gateways['cod']);
    				break; // Stop the loop after unsetting the gateway
    			}
    		}
    
    		return $gateways;
    	}
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support James Osborne

    (@jamesosborne)

    Thanks for reaching out @soroka95. If you’d like to share the following I’d be happy to investigate this further:

    1. Your Site Health information. You can use this form to share privately if preferred.??
    2. If you temporarily remove this filter can you conform that the Site Kit dashboard does display data as expected? I don’t notice anything obvious that would impact Site Kit, however, it does seem to integrate WooCommerce and Advanced Custom Fields which could impacting reporting.
    3. When checking the Site Kit dashboard from a Chrome browser incognito window does the same occur? If so, please share any browser console errors that appear.?

    Once we have the above we can suggest some checks, while I can also set up an environment similar to your own to check this. Some troubleshooting checks we may suggest are to use the Health Check & Troubleshooting plugin to try and determine possible conflicts.

    Plugin Support James Osborne

    (@jamesosborne)

    As we didn’t receive a response I’ll mark this as resolved. Feel free to open a new support topic if you continue to encounter issues, or reopen this topic and we’d be happy to assist.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Data error in Analytics – The server provided an invalid response.’ is closed to new replies.