function uc_coupon_condition_order_has_coupon in Ubercart Discount Coupons 6
Same name and namespace in other branches
- 7.3 uc_coupon.rules.inc \uc_coupon_condition_order_has_coupon()
- 7.2 uc_coupon.rules.inc \uc_coupon_condition_order_has_coupon()
Check if an order has a coupon applied.
1 string reference to 'uc_coupon_condition_order_has_coupon'
- uc_coupon_ca_condition in ./
uc_coupon.ca.inc - Implementation of hook_ca_condition().
File
- ./
uc_coupon.ca.inc, line 48
Code
function uc_coupon_condition_order_has_coupon($order, $settings) {
if (isset($order->data['coupon'])) {
$check_code = $order->data['coupon'];
}
elseif ($settings['check_current'] && isset($_SESSION['uc_coupon'])) {
$check_code = drupal_strtoupper(trim($_SESSION['uc_coupon']));
}
else {
$check_code = FALSE;
}
if ($check_code) {
// If no codes specified, match any coupon.
if (empty($settings['codes'])) {
return TRUE;
}
// Check codes for exact or wildcard matches.
foreach (explode("\n", $settings['codes']) as $code) {
if (preg_match('/^' . str_replace('\\*', '.*?', preg_quote(strtoupper(trim($code)), '/')) . '$/', $check_code)) {
return TRUE;
}
}
}
return FALSE;
}