I have an Order model that uses a hasMany['lineItems'] relationship. I use the Relation Manager to add LineItems to a new Order. Right now, the Order Total can be calculated only AFTER an Order is saved (since LineItems are only attached to the Order after it has been saved - deferred binding). I want to be able to display OrderTotal while LineItems are being added (and not after Order save) using AJAX so that the user can see how adding LineItems is going to affect the final Total Order Value.
Here are a few screenshots to help understand the situation:
-
Creating a New Order: http://pasteboard.co/12xeUuBK.png
-
Adding Line Items: http://pasteboard.co/12xhWe0O.png
-
Line Items Added (but not attached to this Order till its saved since this uses deferred binding): You can see that the Order Total field is blank. http://pasteboard.co/12xmOYhs.png
- Order saved (total can be calculated now since we know which line items are added to this order): http://pasteboard.co/12xu1BYX.png
Any help will be much appreciated. Feel free to ask for any code here.