Move getWooCommerceSegmentSubscriber() from helper to model
[MAILPOET-2382]
This commit is contained in:
committed by
Jack Kitterhing
parent
dd45a96b94
commit
25d9ffa656
@ -344,6 +344,27 @@ class Subscriber extends Model {
|
||||
return $subscribers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $customer_email
|
||||
* @return bool|Subscriber
|
||||
*/
|
||||
static function getWooCommerceSegmentSubscriber($customer_email) {
|
||||
$wc_segment = Segment::getWooCommerceSegment();
|
||||
return Subscriber::tableAlias('subscribers')
|
||||
->select('subscribers.*')
|
||||
->where('subscribers.email', $customer_email)
|
||||
->join(
|
||||
MP_SUBSCRIBER_SEGMENT_TABLE,
|
||||
'relation.subscriber_id = subscribers.id',
|
||||
'relation'
|
||||
)
|
||||
->where('relation.segment_id', $wc_segment->id)
|
||||
->where('relation.status', Subscriber::STATUS_SUBSCRIBED)
|
||||
->where('subscribers.status', Subscriber::STATUS_SUBSCRIBED)
|
||||
->where('subscribers.is_woocommerce_user', 1)
|
||||
->findOne();
|
||||
}
|
||||
|
||||
function customFields() {
|
||||
return $this->hasManyThrough(
|
||||
__NAMESPACE__ . '\CustomField',
|
||||
|
Reference in New Issue
Block a user