diff --git a/packages/Webkul/Admin/src/Config/system.php b/packages/Webkul/Admin/src/Config/system.php index fdc57c51a..6daa45a16 100644 --- a/packages/Webkul/Admin/src/Config/system.php +++ b/packages/Webkul/Admin/src/Config/system.php @@ -186,6 +186,11 @@ return [ 'title' => 'admin::app.admin.emails.notifications.verification', 'type' => 'boolean', ], + [ + 'name' => 'emails.general.notifications.registration', + 'title' => 'admin::app.admin.emails.notifications.registration', + 'type' => 'boolean', + ], [ 'name' => 'emails.general.notifications.customer', 'title' => 'admin::app.admin.emails.notifications.customer', diff --git a/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerController.php b/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerController.php index 26490697a..60edb2f32 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerController.php @@ -120,7 +120,10 @@ class CustomerController extends Controller $customer = $this->customerRepository->create($data); try { - Mail::queue(new NewCustomerNotification($customer, $password)); + $configKey = 'emails.general.notifications.emails.general.notifications.customer'; + if (core()->getConfigData($configKey)) { + Mail::queue(new NewCustomerNotification($customer, $password)); + } } catch (\Exception $e) { report($e); } diff --git a/packages/Webkul/Admin/src/Listeners/Order.php b/packages/Webkul/Admin/src/Listeners/Order.php index 5b8495589..c6b7e7947 100755 --- a/packages/Webkul/Admin/src/Listeners/Order.php +++ b/packages/Webkul/Admin/src/Listeners/Order.php @@ -28,9 +28,15 @@ class Order public function sendNewOrderMail($order) { try { - Mail::queue(new NewOrderNotification($order)); + $configKey = 'emails.general.notifications.emails.general.notifications.new-order'; + if (core()->getConfigData($configKey)) { + Mail::queue(new NewOrderNotification($order)); + } - Mail::queue(new NewAdminNotification($order)); + $configKey = 'emails.general.notifications.emails.general.notifications.new-admin'; + if (core()->getConfigData($configKey)) { + Mail::queue(new NewAdminNotification($order)); + } } catch (\Exception $e) { report($e); } @@ -48,7 +54,10 @@ class Order return; } - Mail::queue(new NewInvoiceNotification($invoice)); + $configKey = 'emails.general.notifications.emails.general.notifications.new-invoice'; + if (core()->getConfigData($configKey)) { + Mail::queue(new NewInvoiceNotification($invoice)); + } } catch (\Exception $e) { report($e); } @@ -62,7 +71,10 @@ class Order public function sendNewRefundMail($refund) { try { - Mail::queue(new NewRefundNotification($refund)); + $configKey = 'emails.general.notifications.emails.general.notifications.new-refund'; + if (core()->getConfigData($configKey)) { + Mail::queue(new NewRefundNotification($refund)); + } } catch (\Exception $e) { report($e); } @@ -80,9 +92,15 @@ class Order return; } - Mail::queue(new NewShipmentNotification($shipment)); + $configKey = 'emails.general.notifications.emails.general.notifications.new-shipment'; + if (core()->getConfigData($configKey)) { + Mail::queue(new NewShipmentNotification($shipment)); + } - Mail::queue(new NewInventorySourceNotification($shipment)); + $configKey = 'emails.general.notifications.emails.general.notifications.new-inventory-source'; + if (core()->getConfigData($configKey)) { + Mail::queue(new NewInventorySourceNotification($shipment)); + } } catch (\Exception $e) { report($e); } @@ -95,7 +113,10 @@ class Order public function sendCancelOrderMail($order) { try { - Mail::queue(new CancelOrderNotification($order)); + $configKey = 'emails.general.notifications.emails.general.notifications.cancel-order'; + if (core()->getConfigData($configKey)) { + Mail::queue(new CancelOrderNotification($order)); + } } catch (\Exception $e) { report($e); } diff --git a/packages/Webkul/Admin/src/Resources/lang/en/app.php b/packages/Webkul/Admin/src/Resources/lang/en/app.php index 28fdce730..5097621a5 100755 --- a/packages/Webkul/Admin/src/Resources/lang/en/app.php +++ b/packages/Webkul/Admin/src/Resources/lang/en/app.php @@ -1211,6 +1211,7 @@ return [ 'notification_label' => 'Notifications', 'notifications' => [ 'verification' => 'Send verification E-mail', + 'registration' => 'Send registration E-mail', 'customer' => 'Send customer E-mail', 'new-order' => 'Send Order Confirmation E-mail', 'new-admin' => 'Send Admin Invitation E-mail', diff --git a/packages/Webkul/Core/src/Database/Seeders/ConfigTableSeeder.php b/packages/Webkul/Core/src/Database/Seeders/ConfigTableSeeder.php index aff7f9326..d9153ca0e 100644 --- a/packages/Webkul/Core/src/Database/Seeders/ConfigTableSeeder.php +++ b/packages/Webkul/Core/src/Database/Seeders/ConfigTableSeeder.php @@ -36,6 +36,16 @@ class ConfigTableSeeder extends Seeder DB::table('core_config')->insert([ 'id' => 3, + 'code' => 'emails.general.notifications.emails.general.notifications.registration', + 'value' => '1', + 'channel_code' => null, + 'locale_code' => null, + 'created_at' => $now, + 'updated_at' => $now, + ]); + + DB::table('core_config')->insert([ + 'id' => 4, 'code' => 'emails.general.notifications.emails.general.notifications.customer', 'value' => '1', 'channel_code' => null, diff --git a/packages/Webkul/Customer/src/Http/Controllers/RegistrationController.php b/packages/Webkul/Customer/src/Http/Controllers/RegistrationController.php index 4acecaee3..3336a2791 100755 --- a/packages/Webkul/Customer/src/Http/Controllers/RegistrationController.php +++ b/packages/Webkul/Customer/src/Http/Controllers/RegistrationController.php @@ -31,23 +31,24 @@ class RegistrationController extends Controller * CustomerRepository object * * @var Object - */ + */ protected $customerRepository; /** * CustomerGroupRepository object * * @var Object - */ + */ protected $customerGroupRepository; /** * Create a new Repository instance. * - * @param \Webkul\Customer\Repositories\CustomerRepository $customer - * @param \Webkul\Customer\Repositories\CustomerGroupRepository $customerGroupRepository + * @param \Webkul\Customer\Repositories\CustomerRepository $customer + * @param \Webkul\Customer\Repositories\CustomerGroupRepository $customerGroupRepository + * * @return void - */ + */ public function __construct( CustomerRepository $customerRepository, CustomerGroupRepository $customerGroupRepository @@ -79,9 +80,9 @@ class RegistrationController extends Controller { $this->validate(request(), [ 'first_name' => 'string|required', - 'last_name' => 'string|required', - 'email' => 'email|required|unique:customers,email', - 'password' => 'confirmed|min:6|required', + 'last_name' => 'string|required', + 'email' => 'email|required|unique:customers,email', + 'password' => 'confirmed|min:6|required', ]); $data = request()->input(); @@ -110,7 +111,10 @@ class RegistrationController extends Controller if ($customer) { if (core()->getConfigData('customer.settings.email.verification')) { try { - Mail::queue(new VerificationEmail($verificationData)); + $configKey = 'emails.general.notifications.emails.general.notifications.verification'; + if (core()->getConfigData($configKey)) { + Mail::queue(new VerificationEmail($verificationData)); + } session()->flash('success', trans('shop::app.customer.signup-form.success-verify')); } catch (\Exception $e) { @@ -119,7 +123,10 @@ class RegistrationController extends Controller } } else { try { - Mail::queue(new RegistrationEmail(request()->all())); + $configKey = 'emails.general.notifications.emails.general.notifications.registration'; + if (core()->getConfigData($configKey)) { + Mail::queue(new RegistrationEmail(request()->all())); + } session()->flash('success', trans('shop::app.customer.signup-form.success-verify')); //customer registered successfully } catch (\Exception $e) {