Custom line item total calculation
The line-item unit price is used throughout commerce and the total order amount is based on the line-item total value (quantity * unit price). There is no way to circumvent this behavior.

Better would be to add another price field to the line-item Price per length-unit. Hide the default price field and calculate the sales price as you've found in other answers.

Basically this is a pricing rule in Store &gt; Configuration &gt; product pricing rules where you add the event Set the unit price to a specific amount to a calculated value.