Commit b02d22f6833 for woocommerce

commit b02d22f68332ca0839bfc7efffd1f110a4cb9bb3
Author: Taha Paksu <3295+tpaksu@users.noreply.github.com>
Date:   Mon Oct 12 12:50:24 2026 +0300

    test: ensure a thousand-separated flat rate cost is not treated as free (#69636)

diff --git a/plugins/woocommerce/changelog/69636-wooplug-2224-flat-rate-thousand-separator-test b/plugins/woocommerce/changelog/69636-wooplug-2224-flat-rate-thousand-separator-test
new file mode 100644
index 00000000000..bba8594ccf1
--- /dev/null
+++ b/plugins/woocommerce/changelog/69636-wooplug-2224-flat-rate-thousand-separator-test
@@ -0,0 +1,5 @@
+Significance: patch
+Type: dev
+Comment: Add a regression test ensuring a thousand-separated flat rate cost is not treated as free; no production change.
+
+
diff --git a/plugins/woocommerce/tests/php/includes/shipping/flat-rate/class-wc-shipping-flat-rate-test.php b/plugins/woocommerce/tests/php/includes/shipping/flat-rate/class-wc-shipping-flat-rate-test.php
index fce05f07a05..ddefaa6cc0e 100644
--- a/plugins/woocommerce/tests/php/includes/shipping/flat-rate/class-wc-shipping-flat-rate-test.php
+++ b/plugins/woocommerce/tests/php/includes/shipping/flat-rate/class-wc-shipping-flat-rate-test.php
@@ -83,54 +83,6 @@ class WC_Shipping_Flat_Rate_Test extends WC_Unit_Test_Case {
 		$this->assertEquals( 12345.67, $val );
 	}

-	/**
-	 * @testDox Shipping cost with a thousand and decimal separator works as expected.
-	 */
-	public function test_evaluate_cost_sep_thou_dec() {
-		$this->markTestSkipped( 'This test currently fails because we dont support thousand separator in shipping price.' );
-		$val = $this->call_evaluate_cost->call(
-			$this->sut,
-			'12.345,67',
-			array(
-				'qty'  => 1,
-				'cost' => 1,
-			)
-		);
-		$this->assertEquals( 12345.67, $val );
-	}
-
-	/**
-	 * @testDox Shipping cost with two decimal separator works as expected.
-	 */
-	public function test_evaluate_cost_sep_dec_dec() {
-		$this->markTestSkipped( 'This test currently fails because we dont support thousand separator in shipping price.' );
-		$val = $this->call_evaluate_cost->call(
-			$this->sut,
-			'12,345,67',
-			array(
-				'qty'  => 1,
-				'cost' => 1,
-			)
-		);
-		$this->assertEquals( 12345.67, $val );
-	}
-
-	/**
-	 * @testDox Shipping cost with two thousand separator works as expected.
-	 */
-	public function test_evaluate_cost_sep_thou_thou() {
-		$this->markTestSkipped( 'This test currently fails because we dont support thousand separator in shipping price.' );
-		$val = $this->call_evaluate_cost->call(
-			$this->sut,
-			'12.345.67',
-			array(
-				'qty'  => 1,
-				'cost' => 1,
-			)
-		);
-		$this->assertEquals( 1234567, $val );
-	}
-
 	/**
 	 * Percent fee calculation works as expected.
 	 */
@@ -544,4 +496,68 @@ class WC_Shipping_Flat_Rate_Test extends WC_Unit_Test_Case {

 		$this->assertSame( $expected, trim( $result ), 'Entered as "' . $typed . '" on a comma-decimal store.' );
 	}
+
+	/**
+	 * @testdox sanitize_cost() delocalises a plain thousand-separated cost so it is never evaluated as free shipping.
+	 *
+	 * @dataProvider provider_thousand_separated_costs
+	 *
+	 * @param string $value        Raw cost as a merchant would enter it.
+	 * @param string $decimal_sep  Decimal separator for the locale.
+	 * @param string $thousand_sep Thousand separator for the locale.
+	 * @param string $expected     Delocalised cost sanitize_cost() should return.
+	 * @param float  $evaluated    Amount evaluate_cost() should yield for the sanitized cost.
+	 */
+	public function test_sanitize_cost_delocalises_thousand_separated_value( string $value, string $decimal_sep, string $thousand_sep, string $expected, float $evaluated ): void {
+		update_option( 'woocommerce_price_decimal_sep', $decimal_sep );
+		update_option( 'woocommerce_price_thousand_sep', $thousand_sep );
+
+		$sanitized = $this->call_sanitize_cost->call( $this->sut, $value );
+		$this->assertSame( $expected, $sanitized, 'sanitize_cost() should delocalise the thousand-separated value.' );
+
+		$result = $this->call_evaluate_cost->call(
+			$this->sut,
+			$sanitized,
+			array(
+				'qty'  => 1,
+				'cost' => 1,
+			)
+		);
+		$this->assertEqualsWithDelta( $evaluated, $result, 0.0001, 'evaluate_cost() should evaluate the sanitized cost to the expected amount.' );
+	}
+
+	/**
+	 * Plain thousand-separated costs across locales.
+	 *
+	 * Format: [ raw value, decimal separator, thousand separator, sanitized value, evaluated amount ].
+	 *
+	 * @return array
+	 */
+	public function provider_thousand_separated_costs(): array {
+		return array(
+			// period decimal, comma thousand (US).
+			'US thousand separator' => array( '1,234.56', '.', ',', '1234.56', 1234.56 ),
+
+			// comma decimal, period thousand (EU).
+			'EU thousand separator' => array( '1.234,56', ',', '.', '1234.56', 1234.56 ),
+		);
+	}
+
+	/**
+	 * @testdox sanitize_cost() rejects a cost with more than one decimal separator rather than saving a wrong amount.
+	 *
+	 * @testWith ["12.34.56", ".", ","]
+	 *           ["12,34,56", ",", "."]
+	 *
+	 * @param string $value        Cost written with two decimal separators.
+	 * @param string $decimal_sep  Decimal separator for the locale.
+	 * @param string $thousand_sep Thousand separator for the locale.
+	 */
+	public function test_sanitize_cost_rejects_two_decimal_separators( string $value, string $decimal_sep, string $thousand_sep ): void {
+		update_option( 'woocommerce_price_decimal_sep', $decimal_sep );
+		update_option( 'woocommerce_price_thousand_sep', $thousand_sep );
+
+		$this->expectException( InvalidArgumentException::class );
+		$this->call_sanitize_cost->call( $this->sut, $value );
+	}
 }