On the "add to cart" page, I let the user enter "Width" & "Length" to calculate the number of Square Foot as the quantity which works fine with a JS function. Now my client wants to add an "overhead" price to the product based on the selected variations. Is there a way, either an "hidden field" in the form OR a hook in the module where I can put the amount to add to the line item ? Or any other best idea is appreciated as well ! I'm on Craft Commerce 4.

1 Answer 1


You would need to change the price of the line item based on the option data sent in.


  • The worst thing is that you cannot change the total and subtotal, as this is a property read, except adjusters.
    – RomanAvr
    Jun 16, 2022 at 10:36
  • Thanks @Luke for your answer. You pointed me at the right place. However, from what I see, it looks like all the previous line-items are visited in the process. Althought the rules don't change, it will perform calc on already saved items. Is there a way to get a hook on the actual item added to the cart ? Jun 22, 2022 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.