Validating a coupon
2 posts by 2 authors in: Forums > CMS Builder
Last Post: October 25, 2011 (RSS)
I am able to validate a coupon using some of your existing code from the website membership add on... but while validating the coupon, I need to also make sure the coupon relates to the product detail page it's on.
I know how to do it, but I don't know how to write it. here's the code I have that checks the code for existance.
when it checks the code, it also needs to check to make sure it's 'item_reference' matches the detailrecord 'title'
anything you can do would be appreciated.
I know how to do it, but I don't know how to write it. here's the code I have that checks the code for existance.
// validate coupon code
if (!$errorsAndAlerts) {
$count = mysql_select_count_from('coupon_codes', "`code` = '".mysql_escape(@$_REQUEST['couponCode'])."'");
if ($count > 0 && @$_REQUEST['couponCode']) { $errorsAndAlerts .= "Your code has been validated! Please fill out the form below to process your order\n";
$showSignupForm = true; }
else if(!$count > 0 && @$_REQUEST['couponCode']) { $errorsAndAlerts .= "Your code is not valid! Please check the code and try again. If you feel you've gotten this message in error, please contact us.\n"; }
when it checks the code, it also needs to check to make sure it's 'item_reference' matches the detailrecord 'title'
anything you can do would be appreciated.
John Tedesco
Creative Director
JAM Graphics
Creative Director
JAM Graphics
Re: [jtedescojam] Validating a coupon
By Jason - October 25, 2011
Hi John,
You could add this check to the WHERE clause of you mysql_select_count_from() function.
For example:
Hope this helps get you started
You could add this check to the WHERE clause of you mysql_select_count_from() function.
For example:
// validate coupon code
if (!$errorsAndAlerts) {
$count = mysql_select_count_from('coupon_codes', "`code` = '".mysql_escape(@$_REQUEST['couponCode'])."' AND item_reference = '".mysql_escape($detailRecord['title'])."'");
if ($count > 0 && @$_REQUEST['couponCode']) {
$errorsAndAlerts .= "Your code has been validated! Please fill out the form below to process your order\n";
$showSignupForm = true;
}
else if(!$count > 0 && @$_REQUEST['couponCode']) {
$errorsAndAlerts .= "Your code is not valid! Please check the code and try again. If you feel you've gotten this message in error, please contact us.\n";
}
}
Hope this helps get you started
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/