Skip to content

Commit

Permalink
Add source
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael committed Sep 11, 2024
1 parent fbdec94 commit ac7d5f4
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions ecomailemailmarketing/ecomailemailmarketing.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct()
$this->module_key = '3c90ebaffe6722aece11c7a66bc18bec';
$this->name = 'ecomailemailmarketing';
$this->tab = 'emailing';
$this->version = '2.0.20';
$this->version = '2.0.21';
$this->author = 'Ecomail';
$this->need_instance = 0;
$this->ps_versions_compliancy = ['min' => '1.7.0.0', 'max' => _PS_VERSION_];
Expand Down Expand Up @@ -568,7 +568,7 @@ public function hookActionCustomerAccountAdd(array $params): void
->subscribeToList(
Configuration::get('ECOMAIL_LIST_ID'),
array_merge(
['email' => $email],
['email' => $email, 'source' => 'prestashop'],
$nameData,
$birthdayData,
['tags' => array_merge($groupTags, $newsletterTags)]
Expand Down Expand Up @@ -637,7 +637,7 @@ public function hookActionCustomerNewsletterSubscribed(array $params): void
->subscribeToList(
Configuration::get('ECOMAIL_LIST_ID'),
array_merge(
['email' => $customer['email']],
['email' => $customer['email'], 'source' => 'prestashop'],
$nameData,
$birthdayData,
$addressData,
Expand All @@ -651,7 +651,7 @@ public function hookActionCustomerNewsletterSubscribed(array $params): void
$this->getAPI()
->subscribeToList(
Configuration::get('ECOMAIL_LIST_ID'),
['email' => $params['email']]
['email' => $params['email'], 'source' => 'prestashop']
);
}
}
Expand Down Expand Up @@ -718,6 +718,7 @@ public function hookActionValidateOrder(array $params): void
[
'email' => $customer->email,
'tags' => array_merge($newsletterTags, $groupTags),
'source' => 'prestashop',
],
$nameData,
$birthdayData,
Expand Down Expand Up @@ -851,6 +852,7 @@ public function syncCustomers(string $listId, int $offset = 0, bool $forceHttp =
'custom_fields' => [
'PRESTA_LANGUAGE' => Language::getIsoById((int) $customer['id_lang']),
],
'source' => 'prestashop',
];

if (Configuration::get('ECOMAIL_LOAD_NAME')) {
Expand Down Expand Up @@ -992,6 +994,7 @@ public function hookActionCustomerAccountUpdate(array $params): void
{
$newsletter = $params['customer']->newsletter;
$email = $params['customer']->email;
$customerId = $params['customer']->id;

if (Configuration::get('ECOMAIL_API_KEY')) {
$nameData = [];
Expand All @@ -1017,7 +1020,8 @@ public function hookActionCustomerAccountUpdate(array $params): void

$groupTags = [];
if (Configuration::get('ECOMAIL_LOAD_GROUP')) {
$customer = new Customer($email);
$customer = new Customer($customerId);

$groups = $customer->getGroups();

foreach ($groups as $group) {
Expand All @@ -1034,7 +1038,7 @@ public function hookActionCustomerAccountUpdate(array $params): void

$addressData = [];
if (Configuration::get('ECOMAIL_LOAD_ADDRESS')) {
$customer = $customer ?? new Customer($email);
$customer = $customer ?? new Customer($customerId);
$customerAddress = $customer->getAddresses($customer->id_lang);

if (isset($customerAddress[0])) {
Expand All @@ -1055,7 +1059,7 @@ public function hookActionCustomerAccountUpdate(array $params): void
->subscribeToList(
Configuration::get('ECOMAIL_LIST_ID'),
array_merge(
['email' => $email],
['email' => $email, 'source' => 'prestashop'],
$nameData,
$birthdayData,
$addressData,
Expand Down Expand Up @@ -1084,7 +1088,7 @@ public function hookActionSubmitCustomerAddressForm(array $params): void
->subscribeToList(
Configuration::get('ECOMAIL_LIST_ID'),
array_merge(
['email' => $customer->email],
['email' => $customer->email, 'source' => 'prestashop'],
$addressData
)
);
Expand Down

0 comments on commit ac7d5f4

Please sign in to comment.