Data error in Analytics – The server provided an invalid response.
-
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/tTBVFFdjJ71sFunction 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)
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.