cart ? intval( WC()->cart->get_cart_contents_count() ) : null; $order_id = null; if ( isset( $wp->query_vars['order-pay'] ) ) { $order_id = absint( $wp->query_vars['order-pay'] ); } elseif ( isset( $_POST['wcpay_order_id'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification $order_id = absint( $_POST['wcpay_order_id'] ); // phpcs:ignore WordPress.Security.NonceVerification } if ( ! $order_items_count && 0 < $order_id ) { $order = wc_get_order( $order_id ); if ( $order ) { $order_items_count = $order->get_item_count(); } } // According to https://www.php.net/manual/en/function.array-filter.php#111091 // Applying "strlen" as the callback function will remove `false`, `null` and empty strings, but not "0" values. return array_filter( [ 'fraud_prevention_data_shopper_ip_hash' => $this->hash_data_for_fraud_prevention( WC_Geolocation::get_ip_address() ), 'fraud_prevention_data_shopper_ua_hash' => $fingerprint, 'fraud_prevention_data_ip_country' => WC_Geolocation::geolocate_ip( '', true )['country'], 'fraud_prevention_data_cart_contents' => $order_items_count, ], 'strlen' ); } }