Browse Source

Shop, settings, on/off orders via CP

Vova Tkach 5 years ago
parent
commit
2a9449650b

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

@@ -42,6 +42,7 @@ type Config struct {
 				Comment      int
 				Comment      int
 			}
 			}
 			NotifyEmail string
 			NotifyEmail string
+			Enabled     int
 		}
 		}
 	}
 	}
 	API struct {
 	API struct {
@@ -107,6 +108,7 @@ func (this *Config) configDefault() {
 	this.Shop.Orders.RequiredFields.Comment = 0
 	this.Shop.Orders.RequiredFields.Comment = 0
 
 
 	this.Shop.Orders.NotifyEmail = ""
 	this.Shop.Orders.NotifyEmail = ""
+	this.Shop.Orders.Enabled = 1
 
 
 	this.API.XML.Enabled = 0
 	this.API.XML.Enabled = 0
 	this.API.XML.Name = ""
 	this.API.XML.Name = ""

+ 6 - 0
modules/module_settings.go

@@ -576,6 +576,12 @@ func (this *Modules) RegisterModule_Settings() *Module {
 					Value:   (*wrap.Config).Shop.Orders.NotifyEmail,
 					Value:   (*wrap.Config).Shop.Orders.NotifyEmail,
 					Hint:    "Example: example@gmail.com",
 					Hint:    "Example: example@gmail.com",
 				},
 				},
+				{
+					Kind:    builder.DFKCheckBox,
+					Caption: "Accept orders",
+					Name:    "accept-orders",
+					Value:   utils.IntToStr((*wrap.Config).Shop.Orders.Enabled),
+				},
 				{
 				{
 					Kind:   builder.DFKSubmit,
 					Kind:   builder.DFKSubmit,
 					Value:  "Save",
 					Value:  "Save",

+ 8 - 0
modules/module_settings_act_shop.go

@@ -26,6 +26,8 @@ func (this *Modules) RegisterAction_SettingsShop() *Action {
 
 
 		pf_new_order_notify_email := strings.TrimSpace(wrap.R.FormValue("new-order-notify-email"))
 		pf_new_order_notify_email := strings.TrimSpace(wrap.R.FormValue("new-order-notify-email"))
 
 
+		pf_accept_orders := wrap.R.FormValue("accept-orders")
+
 		if !utils.IsNumeric(pf_price_fomat) {
 		if !utils.IsNumeric(pf_price_fomat) {
 			wrap.MsgError(`Must be integer number`)
 			wrap.MsgError(`Must be integer number`)
 			return
 			return
@@ -76,6 +78,10 @@ func (this *Modules) RegisterAction_SettingsShop() *Action {
 			pf_require_comment = "0"
 			pf_require_comment = "0"
 		}
 		}
 
 
+		if pf_accept_orders == "" {
+			pf_accept_orders = "0"
+		}
+
 		(*wrap.Config).Shop.Price.Format = pfi_price_fomat
 		(*wrap.Config).Shop.Price.Format = pfi_price_fomat
 		(*wrap.Config).Shop.Price.Round = pfi_price_round
 		(*wrap.Config).Shop.Price.Round = pfi_price_round
 
 
@@ -93,6 +99,8 @@ func (this *Modules) RegisterAction_SettingsShop() *Action {
 			}
 			}
 		}
 		}
 
 
+		(*wrap.Config).Shop.Orders.Enabled = utils.StrToInt(pf_accept_orders)
+
 		if err := wrap.ConfigSave(); err != nil {
 		if err := wrap.ConfigSave(); err != nil {
 			wrap.MsgError(err.Error())
 			wrap.MsgError(err.Error())
 			return
 			return