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:

How can I Add several Items into the cart at once? (1997) Need help with emailer- 2 issues (1997) Preventing Merchant Settling ? (1997) RAM variables (1997) [OT] Live Chat with Video capability (2008) Shipping.db (1998) Plugin or CGI or both (1997) Nesting [ListFiles] (1998) Appending problem (still) on Solaris (2000) Custom WebCat Prefs ... (1997) referrer (2000) Can I invoke an ssi plugin from within a webcat page (1997) Country & Ship-to address & other fields ? (1997) Searchable Archive: Sender? (1998) OSX 10.1.1 (2001) Anyone Using 4DMail (2004) Multiple prices (1997) OS X permissions to write to Globals directory (2003) TCPConnect and SSL servers (2001) [WebDNA] Froala Editor working with WebDNA (2016)