Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 30 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| Segment_Condition_Woo_Customer | |
0.00% |
0 / 29 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| conditionArg | |
0.00% |
0 / 26 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | /* |
| 3 | * Jetpack CRM |
| 4 | * https://jetpackcrm.com |
| 5 | * |
| 6 | * WooSync: Segment Condition: Is WooCommerce Customer |
| 7 | * |
| 8 | */ |
| 9 | |
| 10 | // block direct access |
| 11 | defined( 'ZEROBSCRM_PATH' ) || exit( 0 ); |
| 12 | |
| 13 | /** |
| 14 | * WooSync: Segment Condition: Is WooCommerce Customer class |
| 15 | */ |
| 16 | class Segment_Condition_Woo_Customer extends zeroBSCRM_segmentCondition { |
| 17 | |
| 18 | public $key = 'is_woo_customer'; |
| 19 | public $condition = array( |
| 20 | 'position' => 1, |
| 21 | 'category' => 'WooSync', |
| 22 | 'operators' => array( 'istrue', 'isfalse' ), |
| 23 | 'fieldname' => 'is_woo_customer', |
| 24 | ); |
| 25 | |
| 26 | /** |
| 27 | * init, here just used to set translated attributes. |
| 28 | */ |
| 29 | public function __construct( $constructionArgs = array() ) { |
| 30 | |
| 31 | // set translations |
| 32 | $this->condition['name'] = __( 'WooCommerce Customer', 'zero-bs-crm' ); |
| 33 | $this->condition['description'] = __( 'Select contacts who are or are not also WooCommerce customers', 'zero-bs-crm' ); |
| 34 | |
| 35 | // fire main class init |
| 36 | $this->init( $constructionArgs ); |
| 37 | } |
| 38 | |
| 39 | public function conditionArg( $startingArg = false, $condition = false, $conditionKeySuffix = false ) { |
| 40 | |
| 41 | global $zbs, $ZBSCRM_t; |
| 42 | |
| 43 | if ( $condition['operator'] == 'istrue' ) { |
| 44 | return array( |
| 45 | 'additionalWhereArr' => |
| 46 | array( |
| 47 | 'is_woo_customer' . $conditionKeySuffix => array( |
| 48 | 'ID', |
| 49 | 'IN', |
| 50 | '(SELECT DISTINCT zbss_objid FROM ' . $ZBSCRM_t['externalsources'] . ' WHERE zbss_objtype = ' . ZBS_TYPE_CONTACT . ' AND zbss_source = %s)', |
| 51 | array( 'woo' ), |
| 52 | ), |
| 53 | ), |
| 54 | ); |
| 55 | } |
| 56 | |
| 57 | if ( $condition['operator'] == 'isfalse' ) { |
| 58 | return array( |
| 59 | 'additionalWhereArr' => |
| 60 | array( |
| 61 | 'is_woo_customer' . $conditionKeySuffix => array( |
| 62 | 'ID', |
| 63 | 'NOT IN', |
| 64 | '(SELECT DISTINCT zbss_objid FROM ' . $ZBSCRM_t['externalsources'] . ' WHERE zbss_objtype = ' . ZBS_TYPE_CONTACT . ' AND zbss_source = %s)', |
| 65 | array( 'woo' ), |
| 66 | ), |
| 67 | ), |
| 68 | ); |
| 69 | } |
| 70 | |
| 71 | return $startingArg; |
| 72 | } |
| 73 | } |