Skip to content

Commit

Permalink
Do not send OptInType as a data field
Browse files Browse the repository at this point in the history
  • Loading branch information
sta1r committed Jul 23, 2024
1 parent 44c5bd1 commit 11ed803
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Model/Sync/Subscriber/SingleSubscriberSyncer.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public function pushContactToSubscriberAddressBook(Contact $contact)
$websiteId = (int) $contact->getWebsiteId();
$subscriberSyncEnabled = $this->helper->isSubscriberSyncEnabled($websiteId);
$subscriberAddressBookId = $this->helper->getSubscriberAddressBook($websiteId);
$optInType = null;

if (!$subscriberSyncEnabled || !$subscriberAddressBookId) {
return null;
}
Expand All @@ -59,11 +61,19 @@ public function pushContactToSubscriberAddressBook(Contact $contact)
)
);

// optInType will be set in $subscriberDataFields if it is 'Double'
// optInType is not a data field - this will be refactored in a future release
foreach ($subscriberDataFields as $i => $field) {
if ($field['Key'] === 'OptInType') {
$optInType = $field['Value'];
unset($subscriberDataFields[$i]);
break;
}
}

return $client->addContactToAddressBook(
$contact->getEmail(),
$subscriberAddressBookId,
null,
$optInType,
$subscriberDataFields
);
}
Expand Down

0 comments on commit 11ed803

Please sign in to comment.