From 8fd27b6c4e96fe0e91ec978602a1ccf7f995c98e Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Wed, 8 Oct 2025 12:58:52 -0300 Subject: [PATCH 1/7] Fix square location ID issues --- square/helpers/FrmSquareLiteConnectHelper.php | 38 +++++++++++++------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/square/helpers/FrmSquareLiteConnectHelper.php b/square/helpers/FrmSquareLiteConnectHelper.php index 14522c2d00..0acad7356e 100644 --- a/square/helpers/FrmSquareLiteConnectHelper.php +++ b/square/helpers/FrmSquareLiteConnectHelper.php @@ -350,7 +350,7 @@ private static function get_mode_value() { } /** - * @param string $mode + * @param string $mode either 'auto', 'live', or 'test'. * @return bool|string */ public static function get_merchant_id( $mode = 'auto' ) { @@ -376,6 +376,7 @@ private static function get_location_id_option_name( $mode = 'auto' ) { } /** + * @param string $mode either 'auto', 'live', or 'test'. * @return string */ private static function get_merchant_currency_option_name( $mode = 'auto' ) { @@ -450,8 +451,8 @@ private static function check_server_for_oauth_merchant_id() { if ( is_object( $data ) && ! empty( $data->merchant_id ) ) { update_option( self::get_merchant_id_option_name( $mode ), $data->merchant_id, 'no' ); - $currency = self::get_merchant_currency( true ); - $location_id = self::get_location_id( true ); + $currency = self::get_merchant_currency( true, $mode ); + $location_id = self::get_location_id( true, $mode ); if ( $currency ) { update_option( self::get_merchant_currency_option_name( $mode ), $currency, 'no' ); @@ -547,17 +548,23 @@ public static function create_subscription( $info ) { * @param bool $force * @return false|string */ - public static function get_location_id( $force = false ) { + public static function get_location_id( $force = false, $mode = 'auto' ) { if ( ! $force ) { - $location_id = get_option( self::get_location_id_option_name() ); + $location_id = get_option( self::get_location_id_option_name( $mode ) ); if ( $location_id ) { return $location_id; } } - $response = self::post_with_authenticated_body( 'get_location_id' ); + $request_body = array(); + if ( 'auto' !== $mode ) { + $_POST['testMode'] = 'test' === $mode ? 1 : 0; + $request_body['frm_square_api_mode'] = $mode; + } + + $response = self::post_with_authenticated_body( 'get_location_id', $request_body ); if ( is_object( $response ) ) { - update_option( self::get_location_id_option_name(), $response->id, 'no' ); + update_option( self::get_location_id_option_name( $mode ), $response->id, 'no' ); return $response->id; } @@ -650,20 +657,27 @@ public static function reset_square_api_integration() { } /** - * @param bool $force + * @param bool $force + * @param string $mode * @return false|string */ - public static function get_merchant_currency( $force = false ) { + public static function get_merchant_currency( $force = false, $mode = 'auto' ) { if ( ! $force ) { - $currency = get_option( self::get_merchant_currency_option_name() ); + $currency = get_option( self::get_merchant_currency_option_name( $mode ) ); if ( $currency ) { return $currency; } } - $response = self::post_with_authenticated_body( 'get_merchant_currency' ); + $request_body = array(); + if ( 'auto' !== $mode ) { + $_POST['testMode'] = 'test' === $mode ? 1 : 0; + $request_body['frm_square_api_mode'] = $mode; + } + + $response = self::post_with_authenticated_body( 'get_merchant_currency', $request_body ); if ( is_object( $response ) && ! empty( $response->currency ) ) { - update_option( self::get_merchant_currency_option_name(), $response->currency, 'no' ); + update_option( self::get_merchant_currency_option_name( $mode ), $response->currency, 'no' ); return $response->currency; } From 45c446ae84aa6b5c742ec6f2e0e3462c0bb52014 Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Wed, 8 Oct 2025 13:17:46 -0300 Subject: [PATCH 2/7] Add a comment --- classes/models/FrmMigrate.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/classes/models/FrmMigrate.php b/classes/models/FrmMigrate.php index f37310aefe..3dae1c58eb 100644 --- a/classes/models/FrmMigrate.php +++ b/classes/models/FrmMigrate.php @@ -325,7 +325,7 @@ private function migrate_data( $old_db_version ) { return; } - $migrations = array( 16, 11, 16, 17, 23, 25, 86, 90, 97, 98, 101 ); + $migrations = array( 16, 11, 16, 17, 23, 25, 86, 90, 97, 98, 101, 104 ); foreach ( $migrations as $migration ) { if ( FrmAppHelper::$db_version >= $migration && $old_db_version < $migration ) { $function_name = 'migrate_to_' . $migration; @@ -395,6 +395,23 @@ public function uninstall() { return true; } + /** + * In older versions of Lite, it's possible we've saved the wrong location ID. + * So force it to get valid values again. + * + * @since x.x + * + * @return void + */ + private function migrate_to_104() { + if ( ! FrmSquareLiteConnectHelper::at_least_one_mode_is_setup() ) { + return; + } + + FrmSquareLiteConnectHelper::get_location_id( true, 'test' ); + FrmSquareLiteConnectHelper::get_location_id( true, 'live' ); + } + /** * Disables summary email for multisite (not the main site) if recipient setting isn't changed. * From db2d128a87d9100bcb0e785291154b5377a6ff66 Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Wed, 8 Oct 2025 13:18:10 -0300 Subject: [PATCH 3/7] Bump db version var --- classes/helpers/FrmAppHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/helpers/FrmAppHelper.php b/classes/helpers/FrmAppHelper.php index 21bfa7359d..704ae9dd46 100644 --- a/classes/helpers/FrmAppHelper.php +++ b/classes/helpers/FrmAppHelper.php @@ -10,7 +10,7 @@ class FrmAppHelper { * * @var int */ - public static $db_version = 103; + public static $db_version = 104; /** * Used by the API add-on. From 5ec757bdeec3e20744c3e20634e8848b895259cc Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Wed, 8 Oct 2025 13:45:29 -0300 Subject: [PATCH 4/7] Add another e2e test string --- tests/cypress/e2e/Forms/formPageDataValidation.cy.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/cypress/e2e/Forms/formPageDataValidation.cy.js b/tests/cypress/e2e/Forms/formPageDataValidation.cy.js index 138e886778..7720c2750e 100644 --- a/tests/cypress/e2e/Forms/formPageDataValidation.cy.js +++ b/tests/cypress/e2e/Forms/formPageDataValidation.cy.js @@ -30,6 +30,7 @@ describe( 'Forms page', () => { 'more than just a wordpress form builder', 'get more done in less time with better wordpress forms', 'power your wordpress site like never before', + 'upgrading for 60% off during our No Brainer Sale!', ] ).to.include( headingText ); } ); } ); From a5ca86740913444159d0d0bacbf1e0e491e648bc Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Wed, 8 Oct 2025 13:54:09 -0300 Subject: [PATCH 5/7] Check individually --- classes/models/FrmMigrate.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/classes/models/FrmMigrate.php b/classes/models/FrmMigrate.php index 3dae1c58eb..d683c74e5f 100644 --- a/classes/models/FrmMigrate.php +++ b/classes/models/FrmMigrate.php @@ -404,12 +404,13 @@ public function uninstall() { * @return void */ private function migrate_to_104() { - if ( ! FrmSquareLiteConnectHelper::at_least_one_mode_is_setup() ) { - return; + if ( FrmSquareLiteConnectHelper::get_merchant_id( 'test' ) ) { + FrmSquareLiteConnectHelper::get_location_id( true, 'test' ); } - FrmSquareLiteConnectHelper::get_location_id( true, 'test' ); - FrmSquareLiteConnectHelper::get_location_id( true, 'live' ); + if ( FrmSquareLiteConnectHelper::get_merchant_id( 'live' ) ) { + FrmSquareLiteConnectHelper::get_location_id( true, 'live' ); + } } /** From c533c5f867586bd198f99285e209352580ae52e5 Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Wed, 8 Oct 2025 13:56:23 -0300 Subject: [PATCH 6/7] Use lower case --- tests/cypress/e2e/Forms/formPageDataValidation.cy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cypress/e2e/Forms/formPageDataValidation.cy.js b/tests/cypress/e2e/Forms/formPageDataValidation.cy.js index 7720c2750e..bd784a83cb 100644 --- a/tests/cypress/e2e/Forms/formPageDataValidation.cy.js +++ b/tests/cypress/e2e/Forms/formPageDataValidation.cy.js @@ -30,7 +30,7 @@ describe( 'Forms page', () => { 'more than just a wordpress form builder', 'get more done in less time with better wordpress forms', 'power your wordpress site like never before', - 'upgrading for 60% off during our No Brainer Sale!', + 'upgrading for 60% off during our no brainer sale!', ] ).to.include( headingText ); } ); } ); From 61bd5f6febd08e229e642518ee6d1cae5a8561ff Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Wed, 8 Oct 2025 14:10:15 -0300 Subject: [PATCH 7/7] Fix the e2e test --- tests/cypress/e2e/Forms/formPageDataValidation.cy.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/cypress/e2e/Forms/formPageDataValidation.cy.js b/tests/cypress/e2e/Forms/formPageDataValidation.cy.js index bd784a83cb..5d70a26f85 100644 --- a/tests/cypress/e2e/Forms/formPageDataValidation.cy.js +++ b/tests/cypress/e2e/Forms/formPageDataValidation.cy.js @@ -18,7 +18,7 @@ describe( 'Forms page', () => { const text = $el.text().trim(); const href = $el.attr( 'href' ); - if ( href && ( text.includes( 'upgrading to PRO' ) || text.includes( 'Get 60% Off Pro!' ) || text.includes( 'Get the Deal' ) || text.match( /GET \d+% OFF|SAVE \d+%/ ) ) ) { + if ( href && ( text.includes( 'upgrading to PRO' ) || text.includes( 'Get 60% Off Pro!' ) || text.includes( 'Get the Deal' ) || text.match( /GET \d+% OFF|SAVE \d+%/ ) || text.includes( 'upgrading for 60% off during our No Brainer Sale!' ) ) ) { cy.origin( 'https://formidableforms.com', { args: { href } }, ( { href } ) => { cy.visit( href ); cy.get( 'h1' ).should( $h1 => { @@ -30,7 +30,6 @@ describe( 'Forms page', () => { 'more than just a wordpress form builder', 'get more done in less time with better wordpress forms', 'power your wordpress site like never before', - 'upgrading for 60% off during our no brainer sale!', ] ).to.include( headingText ); } ); } );