Page 1 of 1

Going loop the loop

Posted: Wed Sep 21, 2005 9:31 am
by stebut05
Hi all,

Have a small problem, would really appreciate any help given as deadline is near!!
The site i have built is working fine, but client has asked for something extra (again!!). I have assigned category id's to each product.

real tree = category one
pot grown = category two
artificial = category three
pre-lit = category four
lights = category five

etc etc.

When a user is 'checking out' they select a delivery zone for shipping and based on the zone they select a delivery charge is assigned. This all works fine, but now the client wants to add a delivery charge for each item in shopping basket that has a category id of 1, 2, 3 or 4.

e.g

1 real tree + 1 light + 4 decorations == one delivery charge

1 real tree + 2 lights + 1 pre-lit tree + 2 decorations = two delivery charges

2 pot grown + 1 real + 1 pre-lit + 5 decorations + 2 lights == 4 delivery charges.


What i need is some sort of loop function i think?? That will loop through all the items in the basket and count the items that have a category id of 1, 2, 3, 4 and then mulitply items by delivery charge. However, i am unsure how to implement this function and would really, really, really appreciate your help. Thanks for all help, advice and suggestions given, thanks

Regards,

Steven

Posted: Wed Sep 21, 2005 9:41 am
by feyd
first you need to flesh out what the logic for the charge stepping is, as I don't see much logic in there... I'm guessing you have the item list stored in a database table, so using an aggregate function like MySQL's COUNT() with a GROUP BY on the category field will yield the resulting counts for each category.. then just apply your charging logic to the results.

Posted: Wed Sep 21, 2005 10:37 am
by stebut05
Thanks, i will apply that now. Thanks again for your help

Regards,

Steven