Skip to content
Snippets Groups Projects
Commit 5edfa3d3 authored by Christel Loftus's avatar Christel Loftus
Browse files

change to weight conversion inside the extension

parent a02c9046
Branches
Tags
1 merge request!6Rates at checkout
......@@ -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];
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment