From 5edfa3d3378429005099411886fa2bbb1cdb9131 Mon Sep 17 00:00:00 2001
From: "@ChristelLoftus" <christel@bob.co.za>
Date: Thu, 15 Aug 2024 13:49:18 +0200
Subject: [PATCH] change to weight conversion inside the extension

---
 Plugin/AddWeightUnitToOrderPlugin.php | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/Plugin/AddWeightUnitToOrderPlugin.php b/Plugin/AddWeightUnitToOrderPlugin.php
index 6beb3c8..8efcf0d 100644
--- a/Plugin/AddWeightUnitToOrderPlugin.php
+++ b/Plugin/AddWeightUnitToOrderPlugin.php
@@ -29,12 +29,19 @@ class AddWeightUnitToOrderPlugin
             \Magento\Store\Model\ScopeInterface::SCOPE_STORE
         );
 
-        if ($weightUnit) {
+        if ($weightUnit === 'lbs') {
             foreach ($order->getItems() as $orderItem) {
-                $orderItem->setData('product_type', $weightUnit);
+                // Get the current weight of the item
+                $weight = $orderItem->getWeight();
+
+                // Convert weight from lbs to kg
+                $convertedWeight = $weight * 0.45359237;
+
+                // Set the converted weight back to the item
+                $orderItem->setData('weight', $weight);
             }
         }
-
+        
         return [$order];
     }
 }
-- 
GitLab