From e1b76d2e0dd076f218cb6ac45baaafbdd787afdc Mon Sep 17 00:00:00 2001 From: objec Date: Wed, 8 Apr 2026 13:33:32 +0400 Subject: [PATCH] Update MailchimpPlugin.php - Replaced full declarations with an import - Added exception to use the return value of subscribeCustomer() Signed-off-by: objec --- app/Plugins/MailchimpPlugin.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Plugins/MailchimpPlugin.php b/app/Plugins/MailchimpPlugin.php index 4de254b1d..231be7da1 100644 --- a/app/Plugins/MailchimpPlugin.php +++ b/app/Plugins/MailchimpPlugin.php @@ -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()}"); } }