This is a follow on to a question I asked this afternoon. I need to parse a query string, excise certain bits and manipulate others in order to do some calculations. As written the shopping cart (JCart), creates a querystring and sends that information to PayPal for them to process. I need to be able to parse the querystring, find the price of one of the products, subtract that from the total, calculate tax on the remainder and add that to the querystring going to PayPal.
I can create my own string to the purposes of calculation so, for no particular reason, I created the attached. Product names are first, quantity, second and item cost is third. From this I need to do the following:
1. Determine the sum of all amounts that are not associated with the 'Trading Post' entry - probably easiest to multiply the prices by quantity, sum that and figure out the tax on that.
If anyone has an easy way or elegant way to do all that I'd sure appreciate some help with it. I've been slogging through it but my way is very plodding - embarassingly so. I just don't know another way at this point - explode the string, get a count, find out how many items there are in the array by getting the numbers between the '_" and "=",
getting the position of the Trading Post item, etc, etc.
A few things to mention:
1. The string could be as small as 1 item or as large as 20.
2. The Trading Post item could be anywhere in the string - it's dependent on when it was added to the shopping cart.
3. Not all carts and thus not all strings will have a Trading Post item.
As always, thank so much in advance.