@hussn this is typically handled by setting the price and inventory quantity to correlate to a small size.
So 1 gram of nuts for $1.00 would be 10 centigrams of inventory at $0.01 each etc.
Similar for lbs and ounces
We are the developer behind the 5-star rated Sell Products by Weight for POS app which solves this issue for in-person sales: https://apps.shopify.com/sell-products-by-weight. Our app enables scale integration, inventory adjustment, COGS reporting, tax-exempt sales, etc.
We are now beginning development to extend functionality to online sales. If you have a need for this, can you please fill out this brief questionnaire so that we can better understand the use case? https://forms.gle/vjMUzZ3wZxHWYmCo7
Thank you very much.