From 2a8061edeef1656df9f19bfca64e5b347d67601e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lucas=20Garc=C3=ADa?= <lucas@codeccoop.org>
Date: Thu, 25 Apr 2024 17:52:59 +0200
Subject: [PATCH] feat: try int casting on wpcf7 hidden fields

---
 includes/integrations/wpcf7/class-integration.php | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/includes/integrations/wpcf7/class-integration.php b/includes/integrations/wpcf7/class-integration.php
index 3b754bc..58b8a81 100644
--- a/includes/integrations/wpcf7/class-integration.php
+++ b/includes/integrations/wpcf7/class-integration.php
@@ -88,11 +88,13 @@ class Integration extends BaseIntegration
             $i = array_search($key, array_column($form_data['fields'], 'name'));
             $field = $form_data['fields'][$i];
 
-            if ($field['type'] === 'number') {
-                $number = (float) $val;
-                if ((string) $number === $val) {
-                    $data[$key] = $number;
+            if ($field['type'] === 'hidden') {
+                $number_val = (float) $val;
+                if ((string) $number_val === $val) {
+                    $data[$key] = $number_val;
                 }
+            } elseif ($field['type'] === 'number') {
+                $data[$key] = (float) $val;
             } elseif ($field['type'] === 'file' || $field['type'] === 'submit') {
                 unset($data[$key]);
             }
-- 
GitLab