<p>You would need to change the price of the line item based on the option data sent in.</p>
<p><a href="https://craftcms.com/knowledge-base/dynamically-customizing-line-item-prices" rel="nofollow noreferrer">https://craftcms.com/knowledge-base/dynamically-customizing-line-item-prices</a></p>

CC BY-SA 4.0
2022-06-16T10:36:49.670Z
The worst thing is that you cannot change the total and subtotal, as this is a property read, except adjusters.
RomanAvr
CC BY-SA 4.0
2022-06-22T12:37:39.167Z
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 ?
Sylvain Tremblay
CC BY-SA 4.0
2022-06-15T12:36:12.867Z
2022-06-15T12:36:12.867Z
Luke Holder
<p>On the &quot;add to cart&quot; page, I let the user enter &quot;Width&quot; &amp; &quot;Length&quot; to calculate the number of Square Foot as the quantity which works fine with a JS function. Now my client wants to add an &quot;overhead&quot; price to the product based on the selected variations. Is there a way, either an &quot;hidden field&quot; 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.</p>

<plugin-craftcommerce><plugin-craftcommerce4>
Add amount to cart line item
# Add amount to cart line item

(Asked by: username_0 on 2022-06-15)

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.

**Tags:** plugin-craftcommerce, plugin-craftcommerce4

---

## 1 answers

### Answer by username_1 on 2022-06-15. Score: 1 | Accepted answer

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

<https://craftcms.com/knowledge-base/dynamically-customizing-line-item-prices>

> **Comments:**
> **username_2**: The worst thing is that you cannot change the total and subtotal, as this is a property read, except adjusters.  
> **username_0**: 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 ?  

---

