RE: formula.db, adding option prices

This WebDNA talk-list message is from

1997


It keeps the original formatting.
numero = 13170
interpreted = N
texte = Sandy ->I have a detail page that has radio buttons for customers to pick >options for the product. These radio button options are variables >TextA, textb and textc for the shopping cart. They are added fine to >the shopping cart (via the $add&db=. . .)and show up as passed variables >to the shopping cart page (when I do a [formsvariable]). >The formula.db equation works fine when I don't try to add additional >prices for product options. It works fine when I make it a formula and >add integers to the product price. It doesn't work when I try to do a >lookup on the textA,B,C value for the price delta on that option. >Here's a sample of code that won't work in the formula.db for price. >[math][lookup >db=inventory.db&lookInField=sku&value=[sku]&returnField=standardcost]+[lookup >db=option3.db&lookInField=optkey3&value=[textC]&returnField=pdelta3][/math] >The option3 lookup formula works fine when I put it on the shoppingcart >page, outside of the formula.db >I'm afraid it is a catch 22 on the value of textC. The formula is >calculated before textC is passed to the next page or stored in the >shopping cart. Is this happening? If so, how do I get around it? >I have tried doing a [addlineitems] on the shopping cart page instead of >the $add on the detail page (allowing easier passing of variables), but >couldn't get the [lineitems] to show on the same page. Should this >work?I think I see what you mean - WebCatalog looks up the price in formulas.db and adds it to the cart at the same time it is adding TextA, etc.., so these values aren't available for calculation. What I would recommend is that you take these options as simple form variables instead of adding them to the cart right away, then use these variables in your price formula. Instead of having your form action go to ..showcart.tmpl$add.., you would just have it point to showcart.tmpl. You could name your variables something that contained a number, so you might end up with size1, size2, color1, color2, etc.On the showcart.tmpl page (or wherever you'll be adding these items to the shopping cart), you could loop through the number of items they had selected with a [loop] context, using an [addlineitem] context to add each product to the cart. If you use the actual form variables instead of 'textC' in the price formula (in formulas.db), you should get correct results, and you can also set 'textC' to the correct form variable in that same [addlineitem] context.Finally, you can use an [orderfile] context to actually display the contents of your shopping cart.This may be needlessly complicated, and I'm not sure I've explained it clearly, but it should allow you to do what you are trying to do. If you need more details, please let me know.I hope this helps,Marc Eagle StarNine Technologies http://www.smithmicro.com/ Associated Messages, from the most recent to the oldest:

    
  1. RE: formula.db, adding option prices (Marc Eagle 1997)
Sandy ->I have a detail page that has radio buttons for customers to pick >options for the product. These radio button options are variables >TextA, textb and textc for the shopping cart. They are added fine to >the shopping cart (via the $add&db=. . .)and show up as passed variables >to the shopping cart page (when I do a [formsvariable]). >The formula.db equation works fine when I don't try to add additional >prices for product options. It works fine when I make it a formula and >add integers to the product price. It doesn't work when I try to do a >lookup on the textA,B,C value for the price delta on that option. >Here's a sample of code that won't work in the formula.db for price. >[math][lookup >db=inventory.db&lookInField=sku&value=[sku]&returnField=standardcost]+[lookup >db=option3.db&lookInField=optkey3&value=[textC]&returnField=pdelta3][/math] >The option3 lookup formula works fine when I put it on the shoppingcart >page, outside of the formula.db >I'm afraid it is a catch 22 on the value of textC. The formula is >calculated before textC is passed to the next page or stored in the >shopping cart. Is this happening? If so, how do I get around it? >I have tried doing a [addlineitems] on the shopping cart page instead of >the $add on the detail page (allowing easier passing of variables), but >couldn't get the [lineitems] to show on the same page. Should this >work?I think I see what you mean - WebCatalog looks up the price in formulas.db and adds it to the cart at the same time it is adding TextA, etc.., so these values aren't available for calculation. What I would recommend is that you take these options as simple form variables instead of adding them to the cart right away, then use these variables in your price formula. Instead of having your form action go to ..showcart.tmpl$add.., you would just have it point to showcart.tmpl. You could name your variables something that contained a number, so you might end up with size1, size2, color1, color2, etc.On the showcart.tmpl page (or wherever you'll be adding these items to the shopping cart), you could loop through the number of items they had selected with a [loop] context, using an [addlineitem] context to add each product to the cart. If you use the actual form variables instead of 'textC' in the price formula (in formulas.db), you should get correct results, and you can also set 'textC' to the correct form variable in that same [addlineitem] context.Finally, you can use an [orderfile] context to actually display the contents of your shopping cart.This may be needlessly complicated, and I'm not sure I've explained it clearly, but it should allow you to do what you are trying to do. If you need more details, please let me know.I hope this helps,Marc Eagle StarNine Technologies http://www.smithmicro.com/ Marc Eagle

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:

Webcat 3 Bug?!?! Netscape + Protect + Posted Form (1998) Reload adding to cart (2001) f2 download problems (1997) Resume Catalog ? (1997) Generating Options for a Form. (1997) New Command prefs ... (1997) Robert Minor duplicate mail (1997) Snake Bites (1997) Ship Cost Not working (2000) Email notification to one of multiple vendors ? (1997) WebCat2 - many [carts] on one template page? (1997) Getting Emailer to send mail (1997) [Sum] function? (1997) Upgrading from version (1998) 2nd WebCatalog2 Feature Request (1996) showcart (2000) WebCatalog for guestbook ? (1997) Server Freeze (1998) tpl and Explorer (1998) searching problem (1998)