Re: setitems, one more thing

This WebDNA talk-list message is from

1997


It keeps the original formatting.
numero = 12415
interpreted = N
texte = >The [setlineitem] command makes the quantity and price format right for each indivual lineitem, but when calculating the subtotal of ALL lineitems, the lower than minimum >quantity arises again.>Is there one more setlineitem commmand I need to do for the [subtotal]?OK, that's a subtle side-effect because you are probably displaying the [subtotal] in the context of the _old_ cart, rather than the newly-modified one. The simple answer is to move your [subtotal] tag *inside* the [/OrderFile] ending context tag.Here's why:Everything you display on an invoice or cart page (as a result of $Add, $ShowCart, $Purchase, etc.) is effectively 'wrapped' inside an [OrderFile] context. When you change things with [SetLineItem], those changes are not visible because WebCatalog has sort of memorized all the order information. So you have to explicitly tell it to re-read the order file so you can get at the new information. It all depends on the nesting of the contexts.-- cart.tmpl -- (Implied [OrderFile] context, based on cart# passed in thru $Add) Any [tags] you put here will come from the *old* order file information [subtotal] <-- comes from *old* order file [OrderFile ShoppingCarts/[cart]] Any [tags] you put here will come from the *new* order file information [subtotal] <-- comes from *new* order file [/OrderFile] Any [tags] you put here will come from the *old* order file information, because at this point we are no longer inside the OrderFile context a few lines up from here(End of implied [OrderFile] context) ---------------This nesting concept of containers is very important to understanding WebCatalog. WebCatalog always looks 'from the inside out' for the values of [xxx] tags. The nearest container that contains a tag with the proper name will be used.The following is indented to accentuate the nesting. You are not required to indent your WebDNA, and in fact it could all go on a single line (although it would be harder to read). Just remember that every carriage return and space gets sent back out to the client's browser, and will be visible if they view the source.[date] <- gets date from system clock [search] [founditems] [somefield] [search] <- gets value from closest search container with this fieldname [founditems] [somefield] <- gets value from closest search container with this fieldname [date] <- gets date field from database that 'surrounds' this tag [/founditems] [/search] [/founditems] [/search]In the example above, the innermost [date] tag will display the field 'date' from the surrounding database only if that database has a field with the name 'date'. Otherwise it will keep looking outward for a field named 'date' until it finally can't go any more. If no fields named 'date' are found in the containing searched databases, then the standard definition of today's date will be put there.Similarly, [somefield] looks 'out' (or perhaps 'up') one level for a database field of that name. If found in the nearest containing search, then that value is used. Otherwise it keeps looking outward until no more containers are found. Eventually, if no such named field is found anywhere, WebCatalog literally puts the word '[somefield]' (effectively igoring the tag).There is an explanation of this in the online docs under the major heading ContextsGrant Hulbert, V.P. Engineering | ===== Tools for WebWarriors ===== Pacific Coast Software | WebCatalog Pro, WebCommerce Solution 11770 Bernardo Plaza Court | SiteEdit Pro, SiteCheck, PhotoMaster San Diego, CA 92128 | SiteGuard 619/675-1106 Fax: 619/675-0372 | http://www.smithmicro.com Associated Messages, from the most recent to the oldest:

    
  1. Re: setitems, one more thing (Grant Hulbert 1997)
  2. setitems, one more thing (Kevin Furuta 1997)
>The [setlineitem] command makes the quantity and price format right for each indivual lineitem, but when calculating the subtotal of ALL lineitems, the lower than minimum >quantity arises again.>Is there one more setlineitem commmand I need to do for the [subtotal]?OK, that's a subtle side-effect because you are probably displaying the [subtotal] in the context of the _old_ cart, rather than the newly-modified one. The simple answer is to move your [subtotal] tag *inside* the [/OrderFile] ending context tag.Here's why:Everything you display on an invoice or cart page (as a result of $Add, $ShowCart, $Purchase, etc.) is effectively 'wrapped' inside an [orderfile] context. When you change things with [setlineitem], those changes are not visible because WebCatalog has sort of memorized all the order information. So you have to explicitly tell it to re-read the order file so you can get at the new information. It all depends on the nesting of the contexts.-- cart.tmpl -- (Implied [orderfile] context, based on cart# passed in thru $Add) Any [tags] you put here will come from the *old* order file information [subtotal] <-- comes from *old* order file [OrderFile ShoppingCarts/[cart]] Any [tags] you put here will come from the *new* order file information [subtotal] <-- comes from *new* order file [/OrderFile] Any [tags] you put here will come from the *old* order file information, because at this point we are no longer inside the OrderFile context a few lines up from here(End of implied [orderfile] context) ---------------This nesting concept of containers is very important to understanding WebCatalog. WebCatalog always looks 'from the inside out' for the values of [xxx] tags. The nearest container that contains a tag with the proper name will be used.The following is indented to accentuate the nesting. You are not required to indent your WebDNA, and in fact it could all go on a single line (although it would be harder to read). Just remember that every carriage return and space gets sent back out to the client's browser, and will be visible if they view the source.[date] <- gets date from system clock [search] [founditems] [somefield] [search] <- gets value from closest search container with this fieldname [founditems] [somefield] <- gets value from closest search container with this fieldname [date] <- gets date field from database that 'surrounds' this tag [/founditems] [/search] [/founditems] [/search]In the example above, the innermost [date] tag will display the field 'date' from the surrounding database only if that database has a field with the name 'date'. Otherwise it will keep looking outward for a field named 'date' until it finally can't go any more. If no fields named 'date' are found in the containing searched databases, then the standard definition of today's date will be put there.Similarly, [somefield] looks 'out' (or perhaps 'up') one level for a database field of that name. If found in the nearest containing search, then that value is used. Otherwise it keeps looking outward until no more containers are found. Eventually, if no such named field is found anywhere, WebCatalog literally puts the word '[somefield]' (effectively igoring the tag).There is an explanation of this in the online docs under the major heading ContextsGrant Hulbert, V.P. Engineering | ===== Tools for WebWarriors ===== Pacific Coast Software | WebCatalog Pro, WebCommerce Solution 11770 Bernardo Plaza Court | SiteEdit Pro, SiteCheck, PhotoMaster San Diego, CA 92128 | SiteGuard 619/675-1106 Fax: 619/675-0372 | http://www.smithmicro.com Grant Hulbert

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: File Uploads: WebCat/SiteEdit (1998) Summarising on two fields (1998) Question re: FlushDatabases (1997) Searching multiple Databases (1997) Grep and Special Characters (2002) Bookmarked URL with cart (1998) Strange Crash (1998) This is an odd error (2001) [append] and SSL (1997) Security Issues and WebCommerce Solution (1997) shown next / show prev (1998) Trouble with formula.db (1997) Time for a hard questions. (1997) Duplicates (1998) New public beta available (1997) totals (1997) Associative lookup style? + bit more (1997) shrink-wrapped version out yet? (1997) [delete] problem (1997) Multiple prices (1997)