find( array( 'id' => $order_model->customer_id ) ); if ( ! $customer || is_wp_error( $customer ) ) { return; } $name_parts = preg_split( '/\s+/', trim( (string) $customer->name ), 2 ); $customer_data = array( 'email' => $customer->email, 'first_name' => $name_parts[0] ?? '', 'last_name' => $name_parts[1] ?? '', 'status' => 'subscribed', ); try { $this->send_webhook( $webhook_url, $customer_data ); } catch ( \Throwable $e ) { // Ensures silent failure in case of any error. if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) { error_log( 'Zoho Error: ' . $e->getMessage() ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log } } } private function send_webhook( $url, $data ) { $response = wp_remote_post( $url, array( 'body' => wp_json_encode( $data ), 'headers' => array( 'Content-Type' => 'application/json', ), 'timeout' => 15, ) ); if ( is_wp_error( $response ) ) { if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) { error_log( 'Zoho Webhook Error: ' . $response->get_error_message() ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log } } } }