Hope you are all good. I have a problem that is I use an extension i.e. select2 which shows all Products’ name in the dropdown list and it works fine to me. In my database, every product has individual price. So, I want to show the sum of all selected products’ price in the next of dropdown. So, I used ajax to send the product id to the controller to find the product price. Unfortunately, I can’t sum all of product price because when I add new product then previous Id of product gets change then price also gets change. But I want to hold the price of products in a variable when product is selected.
Thanks to answer me. I do not understand clearly what you actually mean. Could you explain more for me please. Actually I have no problem to receive the product id through ajax. I saw through firebug console that product id reaches at controller. I retrieve the product price by that id but unfortunately I couldn’t sum all the product price because when I add new product, controller receives new product id and price is being changed. Please could you help me how the way should be to hold product price in variable once multiple product would be added.
url’=>$this->createUrl(‘totalOrderPrice’), //url to call.
----- this line in oyu above code should be like this
url'=>$this->createUrl('Controller/action'), //url to call.
here your action is totalOrderPrice , you have name the controller's name also..
watch this video http://www.youtube.com/watch?v=VHOg_Ks-a5E
you get clear idea to debug this code....
In each time while the action is performing "totalOrderPrice" insert that value in db, and inn every action it should check in db is any value is present in db , id is value is present it should be added to the current value… After submitting the form the db should be cleared… i think this may solve your issue.