function uc_coupon_handler_filter_product_type::query in Ubercart Discount Coupons 6
Same name and namespace in other branches
- 7.3 views/uc_coupon_handler_filter_product_type.inc \uc_coupon_handler_filter_product_type::query()
- 7.2 views/uc_coupon_handler_filter_product_type.inc \uc_coupon_handler_filter_product_type::query()
File
- views/
uc_coupon_handler_filter_product_type.inc, line 18 - Views handler: Coupon filter on "product-type".
Class
- uc_coupon_handler_filter_product_type
- Filter coupons based on what product types they apply to
Code
function query() {
$this->query
->add_field('uc_coupons', 'data');
if (is_array($this->value) && count($this->value)) {
$search = implode("|", $this->value);
$regexp = ".*product_types.*{[^}]*({$search}).*}";
$this->query
->add_where($this->options['group'], "uc_coupons.data " . ($this->options['operator'] !== 'in' ? "NOT " : "") . "REGEXP '%s'", $regexp);
}
}