[ic] Refresh troubles on basket with coupons

Joshua Lavin joshua at kingdomdesign.com
Tue Mar 16 16:46:34 EST 2004

I've been working on implementing coupons codes in the shopping cart. 
It's working, but there's a small glitch:

Following these steps:
1. Enter known bad coupon code
--> basket refreshed and error shown (correct behavior)

2. Enter good coupon code
--> given missing page: Sorry, the page () was not found. The requested 
page (unspecified error) was not found. (bad behavior -- should return 
to basket and apply discount)

When entering a good code in step one, it is applied correctly. It's 
just when entering a code again (after the page has refreshed from 
previously entering a coupon) that I get the missing page.

I know it's got to be something simple, like something missing from my 

I have a development cart setup here (just add an item to the cart, and 
apply a coupon. Good coupon is '555'; bad coupon is '123'):

Here's the coupon form code (at the bottom of basket.html):
<form action="[process secure=1]" method="post">
<div><input type="hidden" name="mv_todo" value="refresh" />
<input type="hidden" name="mv_form_profile" value="check_coupon" />
<h2>Have a coupon code?</h2>
[if errors]<p style="font-weight:bold; color:#c00;">[error name=josh 
[else]<p>[value using]</p>[/else]
<p>Enter it here:&nbsp; <input type="text" size="10" maxlength="14" 
name="coupon" value="[value coupon]" /> &nbsp;
[button text="Apply"]
     [if type=explicit compare="[run-profile check_coupon"]

Which looks to this form profile to check (at top of basket.html):
[seti check_coupon]
     [discount ALL_ITEMS][/discount]
     [query list=1 sql="select expire,discount from coupons where code = 
'[value coupon]'"]
         [if explicit]
             $current = $Tag->time( '', {}, '%Y-%m-%d' );
             $expire = '[sql-param expire]';
             $current = $Tag->filter( 'digits', $current );
             $expire = $Tag->filter( 'digits', $expire );
             return 1 if $current <= $expire;
             return 0;
             [discount code=ALL_ITEMS interpolate=1] $s * 
[calc](100-[sql-param discount]) / 100[/calc] [/discount]
             [value name=using set="[sql-param discount]% discount 
applied." hide=1]
             [error name=josh set="Invalid or expired code."]

Anyone see what I'm doing wrong? Thanks in advance!

Josh Lavin
Kingdom Design   http://www.kdw.us/

More information about the interchange-users mailing list