| 5:16 am on Apr 13, 2003 (gmt 0)|
I'd like to offer help, but man this is grueling stuff. It's very hard for me to understand what each of these lines are accomplishing. A lot of it seems to be checking to make sure the entries are both numeric and not negative.
Also, anything we give you here runs the risk of not aligning well with the rest of the WorldPay code. So this is where I would turn to WorldPay support. What you want to implement is a relatively simple discount scheme, and I'd assume that they have some basic support and instructions somewhere - they are certainly a big enough operation.
The needed logic seems clear enough. The total purchase price is
unitprice + ((quantity-1)*unitprice/2)
The rest of the code seems to be involved with guaranteeing the integrity of the price and quantity variables.
| 2:54 pm on Apr 13, 2003 (gmt 0)|
Thanks, but I already tried WorldPay and gor this response :-
"We don't offer support for this code as it can be a lengthy process to correct a simple error."
Do you know what language the function has been written in? Do you know of any web resources which would be able to help?
| 3:09 pm on Apr 13, 2003 (gmt 0)|
The bit you need to change is the
a += (b * c);
| 3:12 pm on Apr 13, 2003 (gmt 0)|
This might not be a solution but it gets away from focusing on the code and techie stuff. A couple of low-tech folks I know offer volume discounts as separate items or products.
Product A 1 copy at $500
Product B 2 copies at $750
Product C 3 copies at $1,000
Might be a simple to implment fix.
| 6:24 pm on Apr 13, 2003 (gmt 0)|
hmm. It seems that "x" is an element and shouldn't be able to simply be put into the function without "var x=document.getelementbyid(text1)". I think you may have missed something out.
| 6:47 pm on Apr 13, 2003 (gmt 0)|
| 8:20 pm on Apr 13, 2003 (gmt 0)|
|The bit you need to change is the |
a += (b * c);
That's true. With absolutely no guarantee, and suggesting you test any code that you create before putting it into production, I can say I would try this change as a first shot:
a += (b + b*(c-1)/2)
| 8:25 pm on Apr 13, 2003 (gmt 0)|
As and added comment, one thing that concerns me here is why the existing code uses the += operator when the variable a "should" be zero. It seems to me that a simple = would do the job. So there may be some logic behind the existing code that I just don't see.
| 8:52 pm on Apr 13, 2003 (gmt 0)|
What I have done is amend the code as follows :-
This seems to resolve part of the problem and does calculate the correct discount for the first item on the page. However, I have 5 items and implementing this code results in a zero value being returned if any of the other 4 items are selected.
One step forward ....
| 9:07 pm on Apr 13, 2003 (gmt 0)|
Good luck to you. Just keep playing with the code in logical ways and pin down what all the parts are doing.
I can see you'll hit a snag if the other items don't use the same discount scheme.
I also note that you used the plain = operator. Experiment with the += operator. That may play into the problem you already found.
| 10:20 pm on Apr 13, 2003 (gmt 0)|
Looks like it should be:
or with a,b,c:
| 2:04 pm on Apr 14, 2003 (gmt 0)|
Thanks for the help. In the end I went to [forums.webdeveloper.com...] and paid somebody $50 US to sort it out for me. Seems to have done the trick and does exactly what was needed.