Allow unsubscribing from the WooCommerce segment [MAILPOET-1483]

This commit is contained in:
wxa
2019-03-27 10:55:28 +03:00
committed by M. Shull
parent 41212d8a6f
commit 00c9e682ed
2 changed files with 5 additions and 14 deletions

View File

@@ -19,16 +19,13 @@ class SubscriberSegment extends Model {
$subscriber->save();
$wp_segment = Segment::getWPSegment();
$wc_segment = Segment::getWooCommerceSegment();
if (!empty($segment_ids)) {
// unsubscribe from segments
foreach ($segment_ids as $segment_id) {
// do not remove subscriptions to the WP Users or WooCommerce Customers segments
if (($wp_segment !== false && (int)$wp_segment->id === (int)$segment_id)
|| ($wc_segment !== false && (int)$wc_segment->id === (int)$segment_id)
) {
// do not remove subscriptions to the WP Users segment
if ($wp_segment !== false && (int)$wp_segment->id === (int)$segment_id) {
continue;
}
@@ -49,11 +46,6 @@ class SubscriberSegment extends Model {
'segment_id', $wp_segment->id
);
}
if ($wc_segment !== false) {
$subscriptions = $subscriptions->whereNotEqual(
'segment_id', $wc_segment->id
);
}
$subscriptions->findResultSet()
->set('status', Subscriber::STATUS_UNSUBSCRIBED)