uc_coupon_handler_argument_product_type.inc 638 B

12345678910111213141516171819202122232425
  1. <?php
  2. /**
  3. * @file
  4. * Views handler: Coupon filter on "product-type".
  5. */
  6. /**
  7. * Filter coupons based on what product types they apply to
  8. */
  9. class uc_coupon_handler_argument_product_type extends views_handler_argument {
  10. function query() {
  11. $this->ensure_my_table();
  12. $this->query->add_field('uc_coupons', 'data');
  13. if (!empty($this->argument)) {
  14. $regexp = '.*product_types.*{[^}]*(' . $this->argument . ').*}';
  15. $this->query->add_where_expression(0,
  16. 'uc_coupons.data ' . 'REGEXP :re',
  17. array(':re' => $regexp)
  18. );
  19. }
  20. //. ($this->options['operator'] !== 'in' ? "NOT " : "")
  21. }
  22. }