Hi Minesh,
Thanks for the reply! I'll attempt to answer your questions and clarify:
"I'm bit confuse where exacty you need help."
I think the first challenge is how to successfully feed the amount to the add-to-total2 shortcode.
"Is the qty (quantity) is always be 1?"
Yes. In this case, we actually don't need a quantity. That attribute is there because I duplicated another snippet of custom code that you wrote for me a while back, named "calculate_sum". In calculate_sum, a shortcode is used in the view to loop through a series of Aid Items, multiply their quantity times cost to get the total cost, then add them up. Like this:
Aid Request (one Aid Request has many Aid Items)
---
Aid Item qty x cost
Aid Item qty x cost
Aid Item qty x cost
---
Total Cost (= sum total of each qty x cost)
But in this case, we're adding up the total cost for each Aid Request (in other words, the total cost that was calculated by "calculate_sum"), like this:
Aid Yearly Total (one Aid Yearly Total has many Aid Requests)
---
Aid Request Total Cost
Aid Request Total Cost
Aid Request Total Cost
So practically speaking, an Aid Request has one total cost (i.e., always a quantity of 1; or we could just remove all reference to quantity from the custom code "calculate_sum_for_each_aid_request").
"As I understand - the total calculated by view [wpv-view name="sum-cost-of-aid-items-for-specified-aid-request" postid="[wpv-post-id]"] is corrrect? am I right?"
Yes, that number is correct. That said, I noticed that the view is returning a formatted number, so I duplicated it and created the view "sum-cost-of-aid-items-for-specified-aid-request-raw-number" to output a raw, unformatted number (thinking that the formatting might be part of the problem).
"As I undertand - you want to pass the total return by view [wpv-view name="sum-cost-of-aid-items-for-specified-aid-request" postid="[wpv-post-id]"] to the "price" attribute of your custom shortcode "add-to-total2" and what about the qty? it will be always the same as 1?"
Yes, correct, and as described above, the quantity is always 1.
"I also would like to to from what amount you want to deduct the total?"
Yes, the total will be deducted from the Allocation for that Aid Account for that Year (see screenshot; in the view, this number is returned from another view: [wpv-view name="display-aid-allocation-amount-for-account-by-year" output='raw'] ), like so (using hidden link as our example):
2023 Allocation: for account named "4 Roundup: Resource Stewardship & Science Projects": $181,737.00
minus Aid Request Total Cost
minus Aid Request Total Cost
minus Aid Request Total Cost
---
Amount Remaining (= Aid Yearly Totals.aid-amount minus the sum of Total Cost for each Aid Request)
So I suppose that we could say the end goal is to calculate that "Amount Remaining" number, which would be returned at the bottom of the table.
I hope that clarifies all your questions. Thanks for the assist, and let me know if anything's not clear.
Best,
David