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.
Then add up all those numbers for of the rows and update the field value of the Total field using jQuery.
There is a chance to get the deferred items: https://github.com/responsiv/pay-plugin/blob/master/models/Invoice.php#L158
You just need to refresh the form (or only the total field) in this case.
1-4 of 4