Re: Find Duplicates in Cart

This WebDNA talk-list message is from

2001


It keeps the original formatting.
numero = 37404
interpreted = N
texte = Clint Davis wrote: > > As you can see, I understand the process. I just can't get the code > to work as it should.I think the tinystore example code is what is throwing you off. What you posted is just looping over the formvariables, not the lineitems, and you are always adding a new line item, instead of checking to see if there is a line there already. I am not clear whether the current code works at all, or just works as long as you are adding a new record to the cart.After the [formvariables] loop (i.e. as soon as you know what SKU the user checked on the previous page), you need to see if that SKU is already in the cart and process it, something like this (NOT TESTED):[text]done=no[/text] [lineitems] [if [SKU]=[value]][then] [!] we already have this item in the cart [/!] [setlineitem db=db=restaurants.db&cart=[cart]&index=[lineindex]]quantity=[Interpret][qty_[math]the_index[/math]][/Interpret][/setlineitem] [text]done=yes[/text] [/then][/if] [/lineitems][if [done]=no][then] [!] we didn't find this item in the cart [/!] [addlineitem ...] [/then][/if]And this code will be repeated for every line they checked on the first page (and the cart lines will be walked that many times).Note that this is very confusing because you are referring to index and lineindex and the_index as three completely independent values. Personally, I would have a page where the user would click add for each line and have it post to the same page and do the add there, then redisplay the choices. The cart page would then be only a display of what is in the cart.HTHJohn-- John Peacock Director of Information Research and Technology Rowman & Littlefield Publishing Group 4720 Boston Way Lanham, MD 20706 301-459-3366 x.5010 fax 301-429-5747------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://search.smithmicro.com/ Associated Messages, from the most recent to the oldest:

    
  1. Re: Find Duplicates in Cart (John Peacock 2001)
  2. Re: Find Duplicates in Cart (Clint Davis 2001)
  3. Re: Find Duplicates in Cart (John Peacock 2001)
  4. Find Duplicates in Cart (Clint Davis 2001)
Clint Davis wrote: > > As you can see, I understand the process. I just can't get the code > to work as it should.I think the tinystore example code is what is throwing you off. What you posted is just looping over the formvariables, not the lineitems, and you are always adding a new line item, instead of checking to see if there is a line there already. I am not clear whether the current code works at all, or just works as long as you are adding a new record to the cart.After the [formvariables] loop (i.e. as soon as you know what SKU the user checked on the previous page), you need to see if that SKU is already in the cart and process it, something like this (NOT TESTED):[text]done=no[/text] [lineitems] [if [SKU]=[value]][then] [!] we already have this item in the cart [/!] [setlineitem db=db=restaurants.db&cart=[cart]&index=[lineindex]]quantity=[interpret][qty_[math]the_index[/math]][/Interpret][/setlineitem] [text]done=yes[/text] [/then][/if] [/lineitems][if [done]=no][then] [!] we didn't find this item in the cart [/!] [addlineitem ...] [/then][/if]And this code will be repeated for every line they checked on the first page (and the cart lines will be walked that many times).Note that this is very confusing because you are referring to index and lineindex and the_index as three completely independent values. Personally, I would have a page where the user would click add for each line and have it post to the same page and do the add there, then redisplay the choices. The cart page would then be only a display of what is in the cart.HTHJohn-- John Peacock Director of Information Research and Technology Rowman & Littlefield Publishing Group 4720 Boston Way Lanham, MD 20706 301-459-3366 x.5010 fax 301-429-5747------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://search.smithmicro.com/ John Peacock

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

RE: 2nd WebCatalog2 Feature Request (1996) WebCat2_Mac RETURNs in .db (1997) Help!!!! Purchases not going through! (1997) Installation webCatalog (French speakers please help) (1998) Been meaning to ask... (1997) [ShowIf] and empty fields (1997) More questions about serial number dishing (1997) Searching for all records (1998) WebCatalog Upgrade Pricing? (1997) WebDNA 4.5.1 Now Available (2003) Plugin or CGI or both (1997) can webcat determine an image's pixel dimensions? (2000) Stopping bad HTML propagation ? (1997) [WebDNA] Problem with Cookies in IE and Safari (2009) Multiple Newcarts (1996) acgi to plugin migration problems (2000) Reversed words (1997) Math with Time (1997) RAM variables (1997) emailer (1997)