From 4bcbdcc5629fe642be260ff5cd5f6e0421655028 Mon Sep 17 00:00:00 2001 From: Antony Thorpe <1023740+AntonyThorpe@users.noreply.github.com> Date: Fri, 26 Apr 2024 07:55:54 +1200 Subject: [PATCH] Update OrderEmailNotifier.php - Add the ability to blind copy the status change emails to the administrator - Add private static variables to the class - update the example_config.yml - update the ci.yml to make the 8.1 prf-low tests work in Github Actions --- .github/workflows/ci.yml | 4 +++- example_config.yml | 6 ++++++ src/Checkout/OrderEmailNotifier.php | 27 ++++++++++++++++++++++++++- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 54a8d00c..e6cb6432 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,4 +13,6 @@ jobs: composer_require_extra: phpunit/phpunit:^9.5 silverstripe/silverstripe-omnipay:dev-main - php-http/discovery:^1.18.1 + php-http/discovery:^1.19.4 + symfony/http-foundation:^6.4.4 + moneyphp/money:^4.5.0 diff --git a/example_config.yml b/example_config.yml index d819e75d..6a122138 100644 --- a/example_config.yml +++ b/example_config.yml @@ -6,6 +6,12 @@ SilverShop\Checkout\CheckoutConfig: member_creation_enabled: true membership_required: true +# Send a bcc copy of order & status change emails to the administrator +SilverShop\Checkout\OrderEmailNotifier: + bcc_confirmation_to_admin: true + bcc_receipt_to_admin: true + bcc_status_change_to_admin: true + SilverStripe\Control\Email\Email: admin_email: example@example.com diff --git a/src/Checkout/OrderEmailNotifier.php b/src/Checkout/OrderEmailNotifier.php index 2c307792..be228aba 100644 --- a/src/Checkout/OrderEmailNotifier.php +++ b/src/Checkout/OrderEmailNotifier.php @@ -23,13 +23,34 @@ class OrderEmailNotifier use Injectable; use Configurable; + /** + * bcc Confirmation Emails to Admin + * + * @var boolean + */ + private static $bcc_confirmation_to_admin = false; + + /** + * bcc Receipt Emails to Admin + * + * @var boolean + */ + private static $bcc_receipt_to_admin = false; + + /** + * bcc Status Change Emails to Admin + * + * @var boolean + */ + private static $bcc_status_change_to_admin = false; + /** * @var Order $order */ protected $order; /** - * @var bool + * @var boolean */ protected $debugMode = false; @@ -244,6 +265,10 @@ public function sendStatusChange($title, $note = null) ] ); + if (self::config()->bcc_status_change_to_admin) { + $email->setBcc(Email::config()->admin_email); + } + if ($this->debugMode) { $result = $this->debug($email); } else {