You are here

function uc_coupon_handler_filter_product_type::query in Ubercart Discount Coupons 7.3

Same name and namespace in other branches
  1. 6 views/uc_coupon_handler_filter_product_type.inc \uc_coupon_handler_filter_product_type::query()
  2. 7.2 views/uc_coupon_handler_filter_product_type.inc \uc_coupon_handler_filter_product_type::query()

Add this filter to the query.

Due to the nature of fapi, the value and the operator have an unintended level of indirection. You will find them in $this->operator and $this->value respectively.

Overrides views_handler_filter_in_operator::query

File

views/uc_coupon_handler_filter_product_type.inc, line 19
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_expression($this->options['group'], "uc_coupons.data " . ($this->options['operator'] !== 'in' ? "NOT " : "") . "REGEXP :re", array(
      ':re' => $regexp,
    ));
  }
}