griffin
Member
I have a php form plugin for a promotional coupon which provides discount on fee for a course as follows:
$coupon_code = JRequest::getVar('register___coupon','');
if (!empty($coupon_code)) {
$db =& JFactory::getDBO();
$db->setQuery("SELECT fee FROM coupons WHERE code = " . $db->Quote($coupon_code));
$discount = $db->loadResult();
if (!empty($discount)) {
$price = $discount;
$formModel->updateFormData('register___fee', $price);
$formModel->updateFormData('register___fee_raw', $price);
}
}
This works fine with the register___fee being updated on the form on submission etc checking the coupon code entered matches the codes in the coupon table.
It displays the coupon price in a cascading dropdown element watching coupon_code entered which has element WHERE QUERY checking expiry date on coupons table is greater than current date.
As you would expect though, a cunning user decided to enter the code from one promotion into a registration for a course that wasn't eligible for the discounted rate.
I would be very grateful for some advice/help on how to include a condition where:
"coupons___location = register___location"
and how to display message "Not Valid" where coupon not valid for that location.
Cheers
$coupon_code = JRequest::getVar('register___coupon','');
if (!empty($coupon_code)) {
$db =& JFactory::getDBO();
$db->setQuery("SELECT fee FROM coupons WHERE code = " . $db->Quote($coupon_code));
$discount = $db->loadResult();
if (!empty($discount)) {
$price = $discount;
$formModel->updateFormData('register___fee', $price);
$formModel->updateFormData('register___fee_raw', $price);
}
}
This works fine with the register___fee being updated on the form on submission etc checking the coupon code entered matches the codes in the coupon table.
It displays the coupon price in a cascading dropdown element watching coupon_code entered which has element WHERE QUERY checking expiry date on coupons table is greater than current date.
As you would expect though, a cunning user decided to enter the code from one promotion into a registration for a course that wasn't eligible for the discounted rate.
I would be very grateful for some advice/help on how to include a condition where:
"coupons___location = register___location"
and how to display message "Not Valid" where coupon not valid for that location.
Cheers