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=123because thenthis 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 forexample 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:>> >> 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]>> >> 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:
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=123because thenthis 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 forexample 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:>> >> 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]>> >> 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
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...