Build Collection from shopping cart Items


#1

I’m struggling with this. I have a shopping cart of items that need to be adjusted.

The products are phone and internet. This app is to issue credit to the customer for time out of service.

My program take in an array of service items (Just in case they want credit for more than one item) And Adds them to the shopping cart.

Sometimes the product will have a dropdown in the shopping cart, where the parent product is a non-editable field, and when I expand it, it will break the product down into it’s catagories, but the labels are still the same, internet----30.00 = (internet----10.00, Internet----20.00)

Because the labels are the same I can’t add each row to the dictionary, because I have 3 rows that are all for the internet (the first row being the total price but that field is not editable) The other rows are fractions of that total price. It sort of looks like this.

Main Internet Total-----------------------------30.00

  • Internet--------------20.00
  • Internet--------------10.00

Main Phone total---------------------------------20.00

  • phone----------------10.00
  • phone----------------10.00

Each field has an area where I can type in the adjustment amount that I want to credit, but it can’t be greater than the total price in the field. I can’t edit the Main total Fields. They are not editable.

It will not allow me to add each adjustment row to a dictionary because it would have the same key “Internet” or “phone”.

To iterate through these rows, I have two for-each loops.
I used find children activity to return the values I wanted. The values are all there.
I’m having one more issue also…

I only want the rows where readOnly = 0 (so that it’s editable)
But the way I have it set up now, It’s printing out each row three or four times. Because it’s going through each price, and then going through each label on every price. So it ends up printing each one 3 times.

I’m not sure how to extract the data here. What is the best way to extract the data in my shopping cart, where duplicates don’t matter, and where I can retrieve them later to compare them.

I can’t issue a credit larger than the total product row amount. So on phone for example. I have two Editable fields 10 dollars and 10 dollars. I can’t put more than 10 dollars in either of those fields, so if the credit that is being requested is greater than what is available, it just knocks the price back down to 10. If I try to put 20 bucks, it knocks it back down to 10 automatically.

So I also need to be able to compare each $ field to the amount requested to make sure that amount is available to credit or it takes a different path that I have set up.

SO I need to somehow add these labels, and values to a collection to be used later, and I have to be able to use them later in comparison operations. Any ideas?