Browse Source

Shop -> New order notify email -> in CP settings

Vova Tkach 5 years ago
parent
commit
56bdf27c7c
3 changed files with 20 additions and 0 deletions
  1. 3 0
      engine/wrapper/config/config.go
  2. 7 0
      modules/module_settings.go
  3. 10 0
      modules/module_settings_act_shop.go

+ 3 - 0
engine/wrapper/config/config.go

@@ -41,6 +41,7 @@ type Config struct {
 				Delivery     int
 				Comment      int
 			}
+			NotifyEmail string
 		}
 	}
 	API struct {
@@ -105,6 +106,8 @@ func (this *Config) configDefault() {
 	this.Shop.Orders.RequiredFields.Delivery = 0
 	this.Shop.Orders.RequiredFields.Comment = 0
 
+	this.Shop.Orders.NotifyEmail = ""
+
 	this.API.XML.Enabled = 0
 	this.API.XML.Name = ""
 	this.API.XML.Company = ""

+ 7 - 0
modules/module_settings.go

@@ -569,6 +569,13 @@ func (this *Modules) RegisterModule_Settings() *Module {
 							`</div>`
 					},
 				},
+				{
+					Kind:    builder.DFKText,
+					Caption: "New order notify email",
+					Name:    "new-order-notify-email",
+					Value:   (*wrap.Config).Shop.Orders.NotifyEmail,
+					Hint:    "Example: example@gmail.com",
+				},
 				{
 					Kind:   builder.DFKSubmit,
 					Value:  "Save",

+ 10 - 0
modules/module_settings_act_shop.go

@@ -1,6 +1,8 @@
 package modules
 
 import (
+	"strings"
+
 	"golang-fave/engine/wrapper"
 	"golang-fave/utils"
 )
@@ -22,6 +24,8 @@ func (this *Modules) RegisterAction_SettingsShop() *Action {
 		pf_require_delivery := wrap.R.FormValue("require-delivery")
 		pf_require_comment := wrap.R.FormValue("require-comment")
 
+		pf_new_order_notify_email := strings.TrimSpace(wrap.R.FormValue("new-order-notify-email"))
+
 		if !utils.IsNumeric(pf_price_fomat) {
 			wrap.MsgError(`Must be integer number`)
 			return
@@ -83,6 +87,12 @@ func (this *Modules) RegisterAction_SettingsShop() *Action {
 		(*wrap.Config).Shop.Orders.RequiredFields.Delivery = utils.StrToInt(pf_require_delivery)
 		(*wrap.Config).Shop.Orders.RequiredFields.Comment = utils.StrToInt(pf_require_comment)
 
+		if pf_new_order_notify_email != "" {
+			if utils.IsValidEmail(pf_new_order_notify_email) {
+				(*wrap.Config).Shop.Orders.NotifyEmail = pf_new_order_notify_email
+			}
+		}
+
 		if err := wrap.ConfigSave(); err != nil {
 			wrap.MsgError(err.Error())
 			return