Commit 454fbe99b4 for woocommerce

commit 454fbe99b4df13a0be22e6fe41b854c900722f30
Author: Mayisha <33387139+Mayisha@users.noreply.github.com>
Date:   Tue Dec 30 18:19:44 2025 +0600

    PayPal Standard: Handle invalid items breakdown (#62576)

    * send empty array in items when invalid amount or quantity

    * remove unnecessary log

    * Add changefile(s) from automation for the following project(s): woocommerce

    * update comment

    * update baseline

    * type cast

    * use loose comparison

    * fix lint

    * update logic as per suggestion

diff --git a/plugins/woocommerce/changelog/62576-task-paypal-standard-handle-invalid-items-breakdown b/plugins/woocommerce/changelog/62576-task-paypal-standard-handle-invalid-items-breakdown
new file mode 100644
index 0000000000..676fe7aad7
--- /dev/null
+++ b/plugins/woocommerce/changelog/62576-task-paypal-standard-handle-invalid-items-breakdown
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Fixed order creation failures in PayPal Standard when items contain negative amounts or fractional quantities by omitting the item breakdown in these cases, allowing orders to proceed with the total amount only.
\ No newline at end of file
diff --git a/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-request.php b/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-request.php
index 1e7fd53ae3..23855b7790 100644
--- a/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-request.php
+++ b/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-request.php
@@ -629,11 +629,6 @@ class WC_Gateway_Paypal_Request {
 		}

 		$order_items = $this->get_paypal_order_items( $order );
-		if ( empty( $order_items ) ) {
-			// If we cannot build order items (e.g. negative item amounts),
-			// we should not proceed with the create-order request.
-			throw new Exception( 'Cannot build PayPal order items for order ID: ' . esc_html( $order->get_id() ) );
-		}

 		$src_locale = get_locale();
 		// If the locale is longer than PayPal's string limit (10).
@@ -786,6 +781,7 @@ class WC_Gateway_Paypal_Request {

 	/**
 	 * Get the order items for the PayPal create-order request.
+	 * Returns an empty array if any of the items (amount, quantity) are invalid.
 	 *
 	 * @param WC_Order $order Order object.
 	 * @return array
@@ -795,9 +791,14 @@ class WC_Gateway_Paypal_Request {

 		foreach ( $order->get_items( array( 'line_item', 'fee' ) ) as $item ) {
 			$item_amount = $this->get_paypal_order_item_amount( $order, $item );
-			if ( 'line_item' === $item->get_type() && $item_amount < 0 ) {
-				// PayPal does not accept negative item amounts (for line items).
-				WC_Gateway_Paypal::log( sprintf( 'Order item with negative amount for PayPal order items. Order ID: %d, Item ID: %d, Amount: %f', $order->get_id(), $item->get_id(), $item_amount ), 'error' );
+			if ( $item_amount < 0 ) {
+				// PayPal does not accept negative item amounts in the items breakdown, so we return an empty list.
+				return array();
+			}
+
+			$quantity = $item->get_quantity();
+			// PayPal does not accept zero or fractional quantities.
+			if ( ! is_numeric( $quantity ) || $quantity <= 0 || floor( $quantity ) != $quantity ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseNotEqual
 				return array();
 			}

diff --git a/plugins/woocommerce/phpstan-baseline.neon b/plugins/woocommerce/phpstan-baseline.neon
index 53e75e1a54..4499632727 100644
--- a/plugins/woocommerce/phpstan-baseline.neon
+++ b/plugins/woocommerce/phpstan-baseline.neon
@@ -25089,7 +25089,7 @@ parameters:
 		-
 			message: '#^Parameter \#1 \$text of function esc_html expects string, int given\.$#'
 			identifier: argument.type
-			count: 2
+			count: 1
 			path: includes/gateways/paypal/includes/class-wc-gateway-paypal-request.php

 		-