Skip to content

Commit

Permalink
Update OrderEmailNotifier.php
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
AntonyThorpe committed Apr 25, 2024
1 parent f9574fe commit 4bcbdcc
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions example_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: [email protected]

Expand Down
27 changes: 26 additions & 1 deletion src/Checkout/OrderEmailNotifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 4bcbdcc

Please sign in to comment.