Re: Adding more than one item and QTY to cart

This WebDNA talk-list message is from

2000


It keeps the original formatting.
numero = 34172
interpreted = N
texte = Tim,you need to pass a SKU value for each item that is to end up getting added to the cart. But You have to use neat tricks so that each item has its own SKU passed via a unique var name (since each item has a different sku, you can't simply pass sku=123 because then this code: [formvariables name=qty_&exact=f] [AddLineItem db=/orgmech_internal/orgmech.db&cart=[cart]&sku=[url][SKU][/url]]quantity=[qty_[index]][/AddLineItem] [/formvariables]would lookup the SAME SKU (123) each time it added a different item.Also notice that [qty_[index]] will evaluate to [qty_1], [qty_2], [qty_3], if there were 3 founditems. You should use [interpret][qty_[index]][/interpret] so that it evaluates to the actual value of [qty_1], [qty_2], [qty_3], (ie. 1,7,2 - if for example the user input: 1 of item 1, 7 of item 2, and 2 of item 3.)So this is the kind of technique you would also need for the unique SKU vars. On results.tpl, something like this: [founditems] [SKU] [PRODUCT] $[format .2f][PRICE][/format] / [UNIT] [/founditems]and on cart.tp: [formvariables name=qty_&exact=f] [hideif [URL][value][/URL]=] [AddLineItem db=/orgmech_internal/orgmech.db&cart=[cart]&sku=[url][interpret][sku_[index]][/interpret][/url]]quantity=[interpret][qty_[index]][/interpret][/AddLineItem] [/hideif] [/formvariables]notice you could if you wanted (I think) change '[interpret][qty_[index]][/interpret]' to '[value]' since within the [formvariables] loop the value of the [qty_[index]] var is available via simply '[value]'.the hideif hides the [addlineitem] in the cases where the user did not input any qty.This is all off the top of my head and I may have goofed something up, but you are now hopefully exposed to concepts/techniques that you can use to get it right in case I goofed up.HTH-JohnTim Robinson wrote:> Hi there, > > There's a number of items in the searchable archives, and I HAVE tried. > > I would like to add a number of products to the cart at once, but only if there is a QTY specified for the product. I don't want to have to check a checkbox or anything, just fill in a QTY. > > I understand the cart page needs to have a [FormVariables] and [AddLineItem], but I can't seem to get it to work.... > > Here's the results.tpl stuff: > >
> > > > > > > > > > > [founditems] > > > > > > > [/founditems] > >
SKUPRODUCTQTYPRICE / UNIT
[SKU][PRODUCT]$[format .2f][PRICE][/format] / [UNIT]
> > >
> > Here's the cart.tpl stuff: > > [formvariables name=qty_&exact=f] > [AddLineItem db=/orgmech_internal/orgmech.db&cart=[cart]&sku=[url][SKU][/url]]quantity=[qty_[index]][/AddLineItem] > [/formvariables] > >
> > > > > > > > > > > > > [lineItems] > > > > > > > > > [/lineItems] > >
Line #Product #Item TitleQtyPricePut It Back!
[lineIndex][SKU][PRODUCT]$[format .2f][price][/format] HREF=Cart.tpl?command=remove&db=/orgmech_internal/orgmech.db&index=[lineIndex]&cart=[cart]>Remove Item
>

> >

> > There's obviously something I'm missing. At the moment, the cart.tpl displays the message Error: couldn't find SKU '[SKU]' in product database Error: couldn't find SKU '[SKU]' in product database Error: couldn't find SKU '[SKU]' in product database. > > I want the QTY to remain editable in the cart page. > > Any help would be so hugely appreciated, and good karma is guaranteed... > > Regards, > Tim > > Tim Robinson > Art Director > imagine online > tim@imagine.au.com > http://www.imagine.au.com > ------------------------------------------------------------- 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: Adding more than one item and QTY to cart (John Butler 2000)
  2. Re: Adding more than one item and QTY to cart (Tim Robinson 2000)
  3. Re: Adding more than one item and QTY to cart (Arturo Vargas 2000)
  4. Re: Adding more than one item and QTY to cart (John Butler 2000)
  5. Re: Adding more than one item and QTY to cart (Tim Robinson 2000)
  6. Re: Adding more than one item and QTY to cart (John Butler 2000)
  7. Adding more than one item and QTY to cart (Tim Robinson 2000)
Tim,you need to pass a SKU value for each item that is to end up getting added to the cart. But You have to use neat tricks so that each item has its own SKU passed via a unique var name (since each item has a different sku, you can't simply pass sku=123 because then this code: [formvariables name=qty_&exact=f] [AddLineItem db=/orgmech_internal/orgmech.db&cart=[cart]&sku=[url][SKU][/url]]quantity=[qty_[index]][/AddLineItem] [/formvariables]would lookup the SAME SKU (123) each time it added a different item.Also notice that [qty_[index]] will evaluate to [qty_1], [qty_2], [qty_3], if there were 3 founditems. You should use [interpret][qty_[index]][/interpret] so that it evaluates to the actual value of [qty_1], [qty_2], [qty_3], (ie. 1,7,2 - if for example the user input: 1 of item 1, 7 of item 2, and 2 of item 3.)So this is the kind of technique you would also need for the unique SKU vars. On results.tpl, something like this: [founditems] [SKU] [PRODUCT] $[format .2f][PRICE][/format] / [UNIT] [/founditems]and on cart.tp: [formvariables name=qty_&exact=f] [hideif [url][value][/URL]=] [AddLineItem db=/orgmech_internal/orgmech.db&cart=[cart]&sku=[url][interpret][sku_[index]][/interpret][/url]]quantity=[interpret][qty_[index]][/interpret][/AddLineItem] [/hideif] [/formvariables]notice you could if you wanted (I think) change '[interpret][qty_[index]][/interpret]' to '[value]' since within the [formvariables] loop the value of the [qty_[index]] var is available via simply '[value]'.the hideif hides the [addlineitem] in the cases where the user did not input any qty.This is all off the top of my head and I may have goofed something up, but you are now hopefully exposed to concepts/techniques that you can use to get it right in case I goofed up.HTH-JohnTim Robinson wrote:> Hi there, > > There's a number of items in the searchable archives, and I HAVE tried. > > I would like to add a number of products to the cart at once, but only if there is a QTY specified for the product. I don't want to have to check a checkbox or anything, just fill in a QTY. > > I understand the cart page needs to have a [formvariables] and [addlineitem], but I can't seem to get it to work.... > > Here's the results.tpl stuff: > >
> [cart]> > > > > > > > > > > [founditems] > > > > > > > [/founditems] > >
SKUPRODUCTQTYPRICE / UNIT
[SKU][PRODUCT]$[format .2f][PRICE][/format] / [UNIT]
> > >
> > Here's the cart.tpl stuff: > > [formvariables name=qty_&exact=f] > [AddLineItem db=/orgmech_internal/orgmech.db&cart=[cart]&sku=[url][SKU][/url]]quantity=[qty_[index]][/AddLineItem] > [/formvariables] > >
> [cart]> > > > > > > > > > > > > [lineitems] > > > > > > > > > [/lineItems] > >
Line #Product #Item TitleQtyPricePut It Back!
[lineIndex][SKU][PRODUCT]$[format .2f][price][/format] HREF=Cart.tpl?command=remove&db=/orgmech_internal/orgmech.db&index=[lineIndex]&cart=[cart]>Remove Item
>

> >

> > There's obviously something I'm missing. At the moment, the cart.tpl displays the message Error: couldn't find SKU '[SKU]' in product database Error: couldn't find SKU '[SKU]' in product database Error: couldn't find SKU '[SKU]' in product database. > > I want the QTY to remain editable in the cart page. > > Any help would be so hugely appreciated, and good karma is guaranteed... > > Regards, > Tim > > Tim Robinson > Art Director > imagine online > tim@imagine.au.com > http://www.imagine.au.com > ------------------------------------------------------------- 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 Butler

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:

Who is doing sign-ups-got it (1998) Email down on list? (2002) mail test (1997) mapping fields between databases (2001) Archives... (1997) form crasehes server (1997) Sample Tearoom Search Error (1998) F3 crashing server (1997) Is this google friendly? (2003) Web Catalog vs. ICAT (1997) Re[2]: New syntax feedback for 4.0 (2000) autosensing lanague selection (1997) Install Webcatalog under NT4.0 and Microsoft IIS 2.0 (1997) WriteFile and returns... (2000) OT: Amazon Patents (2000) Misc Stuff That Might Help (1997) PCS Frames (1997) variables in [addlineitem] (1998) Variable security (2000) [UPPERCASE] (1997)