Re: More Discount Pricing thoughts/efforts
This WebDNA talk-list message is from 1998
It keeps the original formatting.
numero = 19104
interpreted = N
texte = At 14:08 Uhr +0000 26.07.1998, Jerry Nielsen wrote:>SELECTING PRICE BASED ON QUANTITY? (This is where I'm stuck, I think?)>==================================>My table in the Invoice.tpl template contains the following WebDNA in the>price cell.>>GOING FURTHER>=============>My final thought on this is that I would use Peter Ostry's code to make>the final [price] calculation for each item...>...>I would test for the quantity fitting within the range of one QTYLVL to>the next and the assign the appropriate PRLVL for that range...>>I'm obviously not getting something. Any help would be appreciated. Is>this a reasonable way to tackle this problem?Jerry,You have overseen a basic behavior of the [price] field: This field has tobe named [price] and not somehow else. I know, that does not come outclearly from the manual, which unfortunately seldom tells when a fieldnameis supposed to have a distinct name and when not.In other words: If there is a field called [price] in the database, it goesto the cart. If there is no such field, no price goes to the cart.You could use formulas.db to transfer something like PRLVL01 into [price]:Not good, you have rather complicated discount-calculations.You could make a quantity-db for each discount range to have a PRICE fieldin each one:Not good either - you reserved 2 digits for the quantity level, so Ibelieve you will have a lot of them...But the following might be the right method:Do not deal directly with the cart, but rather use a temporary db with justtwo fields: sku and price - let us call it tempcart.db and it is alwaysempty, until a user submits an item:[search...] your original database for sku, within [founditems] find out the quantity level [Append...] sku and calculated price to tempcart.db [AddLineItem ...] this new record to the cart! the price goes in automatically (because of the name) the quantity you know already and the description you put in a textfield finally [Delete ...] the record from tempcart.Thats it.Code for quantity calculation is now much easier to write, because you getthe values from your database and you do not deal directly with the cart.And you are not forced to hardcode all your quantity levels. You can evenhandle a list of items which are submitted at once.I think this will fit for you, doesn't it?Ok, to avoid long explanations and heavy posting of code snippets, I builta rough example:http://demo.ostry.com/jerryIf you like some parts of it you can have the templates.Peter__________________________________________Peter Ostry - po@ostry.com - www.ostry.comOstry & Partner - Ostry Internet SolutionsAuhofstrasse 29 A-1130 Vienna Austriafon ++43-1-8777454 fax ++43-1-8777454-21
Associated Messages, from the most recent to the oldest:
At 14:08 Uhr +0000 26.07.1998, Jerry Nielsen wrote:>SELECTING PRICE BASED ON QUANTITY? (This is where I'm stuck, I think?)>==================================>My table in the Invoice.tpl template contains the following WebDNA in the>price cell.>>GOING FURTHER>=============>My final thought on this is that I would use Peter Ostry's code to make>the final [price] calculation for each item...>...>I would test for the quantity fitting within the range of one QTYLVL to>the next and the assign the appropriate PRLVL for that range...>>I'm obviously not getting something. Any help would be appreciated. Is>this a reasonable way to tackle this problem?Jerry,You have overseen a basic behavior of the [price] field: This field has tobe named [price] and not somehow else. I know, that does not come outclearly from the manual, which unfortunately seldom tells when a fieldnameis supposed to have a distinct name and when not.In other words: If there is a field called [price] in the database, it goesto the cart. If there is no such field, no price goes to the cart.You could use
formulas.db to transfer something like PRLVL01 into [price]:Not good, you have rather complicated discount-calculations.You could make a quantity-db for each discount range to have a PRICE fieldin each one:Not good either - you reserved 2 digits for the quantity level, so Ibelieve you will have a lot of them...But the following might be the right method:Do not deal directly with the cart, but rather use a temporary db with justtwo fields: sku and price - let us call it tempcart.db and it is alwaysempty, until a user submits an item:[search...] your original database for sku, within
[founditems] find out the quantity level [Append...] sku and calculated price to tempcart.db [AddLineItem ...] this new record to the cart! the price goes in automatically (because of the name) the quantity you know already and the description you put in a textfield finally [Delete ...] the record from tempcart.Thats it.Code for quantity calculation is now much easier to write, because you getthe values from your database and you do not deal directly with the cart.And you are not forced to hardcode all your quantity levels. You can evenhandle a list of items which are submitted at once.I think this will fit for you, doesn't it?Ok, to avoid long explanations and heavy posting of code snippets, I builta rough example:http://demo.ostry.com/jerryIf you like some parts of it you can have the templates.Peter__________________________________________Peter Ostry - po@ostry.com - www.ostry.comOstry & Partner - Ostry Internet SolutionsAuhofstrasse 29 A-1130 Vienna Austriafon ++43-1-8777454 fax ++43-1-8777454-21
Peter Ostry
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:
AW: AW: Credit card processing - UK (1997)
Unexpected error (1997)
emailer (1997)
Where's Cart Created ? (1997)
Banners (1997)
[OT] Who's got a cool link (2002)
[isfolder] and [filename] (1997)
Multiple fields on 1 input (1997)
New to WebCat, Help. (1998)
Email within tmpl ? (1997)
Re:trouble (1997)
Universal root for WC errors? (1997)
[WebDNA] Apache 2 Error Log Entry (2009)
[OT] Display Glitch (2004)
template not found error (1998)
MacAuthorize order data fields WAS:How To question... (1997)
WCS Newbie question (1997)
Another New Site (1998)
Silly Question (1997)
Upgrade to 4.0 (2001)