Skip to content

Commit

Permalink
fix(mailchimp): selecting mailchimp segments with groups (#1600)
Browse files Browse the repository at this point in the history
* fix(mailchimp): selected segment when segment contains groups

* fix: wrong order of conditions
  • Loading branch information
dkoo authored Aug 19, 2024
1 parent 776f316 commit a698aaa
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/service-providers/mailchimp/ProviderSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@ const getSubAudienceValue = newsletterData => {
const targetId =
( Array.isArray( targetIdRawValue ) ? targetIdRawValue[ 0 ] : targetIdRawValue ).toString() ||
'';
const targetField = recipients?.segment_opts?.conditions?.length
? recipients?.segment_opts?.conditions[ 0 ]?.field
: '';
if ( ! targetField || ! targetId ) {
const targetField =
! recipients?.segment_opts?.saved_segment_id && recipients?.segment_opts?.conditions?.length
? recipients?.segment_opts?.conditions[ 0 ]?.field
: '';
if ( ! targetField && ! targetId ) {
return false;
}
return 'Interests' === recipients?.segment_opts?.conditions[ 0 ]?.condition_type
return ! recipients?.segment_opts?.saved_segment_id &&
'Interests' === recipients?.segment_opts?.conditions[ 0 ]?.condition_type
? `${ targetField || '' }:${ targetId }`
: targetId;
};
Expand Down

0 comments on commit a698aaa

Please sign in to comment.