[ic] Setting order discount using JavaScript

Jonathan Clark interchange-users@interchange.redhat.com
Mon May 13 09:53:01 2002


> -----Original Message-----
> From: interchange-users-admin@interchange.redhat.com
> [mailto:interchange-users-admin@interchange.redhat.com]On Behalf Of
> Scott Kennedy
> Sent: 13 May 2002 14:21
> To: interchange-users@interchange.redhat.com
> Subject: Re: [ic] Setting order discount using JavaScript
>
>
> On Mon, 13 May 2002 cfm@maine.com wrote:
>
> |On Sun, May 12, 2002 at 10:19:49PM -0500, Scott Kennedy wrote:
> |> I'm trying to set a discount for the entire order using a
> combination of
> |> JavaScript and Perl.  The code is on the checkout page which
> may be found at,
> |>
> |>     http://neatway.com/cgi-bin/altchoice/index.html
> |>
> |
> |Be careful that a visitor cannot alter that javascript and post the
> |page with his own discount.  That's a pretty common hack to many
> |carts that carry pricing in the page.
>
> Sorry for the previous post.  I looked the code over and I
> believe that I'm safe
> here because the discounts are calculated in the Perl section.
>
> I'm close, I think, to getting this working 100%.  The problem
> seems to be that
> the values aren't updated right away.  For example, let's say I
> click a radio
> button for a 5% discount (please see included code below) to be
> applied to an
> order totalling $100.  When the checkout form gets refreshed, the
> order total
> should be $95.  Instead, it still shows $100.  As I've said
> before, I have to
> monkey with something in order for the true total to be
> displayed.  Also, the
> total may or may not be correct on the receipt page, if something
> was changed
> prior to submitting the checkout form.
>
[snip]

>         $Document->send("Amount = ", $amount); $Document->send("<BR>");
>
>         if ($amount > 0) {
>                 $Tag->discount('ENTIRE_ORDER', $amount);

I think this should be:

>                 $Tag->discount('ENTIRE_ORDER', '$s -' . $amount);

which is equivalent to [discount ENTIRE_ORDER] $s - 5 [/discount] per the
docs.

Jonathan
Webmaint.