I have a form for creation new order. One order can include several products. Each product has a price. Order’s price equals to sum of prices of all product, included into it.
My form needs to update order’s price, as user sets a quantity for each of the products.
Ideas ?
Use Javascript and the onchange HTML event on the quantity input fields.
When the user changed the quantity, the Javascript can process the form and calculate the new order price. Javascript is able to calculate the total price for a number of items, by using something like this:
Do this for all your items and add all
item_totalvalues to get the total order price.By picking handy ids for your price and quantity fields, you can easily loop this and thus be independent of the amount of items in your order.