[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
form.
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'):
http://www.shopalert.us/shop_dev/books.html
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
show_error=1]</p>
[else]<p>[value using]</p>[/else]
[/if]
<p>Enter it here: <input type="text" size="10" maxlength="14"
name="coupon" value="[value coupon]" />
[button text="Apply"]
[if type=explicit compare="[run-profile check_coupon"]
[/if]
[/button]
</p></div>
</form>
----
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]
[condition]
$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;
[/condition]
[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]
[else]
[error name=josh set="Invalid or expired code."]
[/else]
[/if]
[/query]
[/seti]
----
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