Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update OrderEmailNotifier.php #821

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: example@example.com

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
Loading