Update MailchimpPlugin.php

- Replaced full declarations with an import
- Added exception to use the return value of subscribeCustomer()

Signed-off-by: objec <objecttothis@gmail.com>
This commit is contained in:
objec
2026-04-08 13:33:32 +04:00
parent 84ea65b1bd
commit e1b76d2e0d

View File

@@ -6,6 +6,7 @@ use App\Libraries\Plugins\BasePlugin;
use App\Libraries\Mailchimp_lib;
use CodeIgniter\Events\Events;
use Config\Services;
use Exception;
/**
* Plugin that integrates OSPOS with Mailchimp for customer newsletter subscriptions.
@@ -103,8 +104,10 @@ class MailchimpPlugin extends BasePlugin
log_message('debug', "Customer saved event received for ID: {$customerData['person_id']}");
try {
$this->subscribeCustomer($customerData);
} catch (\Exception $e) {
if (!$this->subscribeCustomer($customerData)) {
throw new Exception("Customer ID {$customerData['person_id']}");
}
} catch (Exception $e) {
log_message('error', "Failed to sync customer to Mailchimp: {$e->getMessage()}");
}
}