Browse Source

Shop order proccess, show example of mobile phone / email in error message

Vova Tkach 5 years ago
parent
commit
04d8bd471e

+ 2 - 0
assets/template/header_html_file.go

@@ -59,6 +59,8 @@ var VarHeaderHtmlFile = []byte(`<!doctype html>
 			var ShopOrderEmptyEmailAddress = 'Please enter your email address';
 			var ShopOrderEmptyDelivery = 'Please enter delivery comment';
 			var ShopOrderEmptyComment = 'Please enter order comment';
+			var ShopOrderNotCorrectMobilePhone = 'For example: +15417543010';
+			var ShopOrderNotCorrectEmailAddress = 'For example: example@gmail.com';
 			var ShopOrderSuccess = '<b>Thank you for your order! We will call you shortly</b>';
 		</script>
 	</head>

+ 2 - 0
hosts/localhost/template/header.html

@@ -57,6 +57,8 @@
 			var ShopOrderEmptyEmailAddress = 'Please enter your email address';
 			var ShopOrderEmptyDelivery = 'Please enter delivery comment';
 			var ShopOrderEmptyComment = 'Please enter order comment';
+			var ShopOrderNotCorrectMobilePhone = 'For example: +15417543010';
+			var ShopOrderNotCorrectEmailAddress = 'For example: example@gmail.com';
 			var ShopOrderSuccess = '<b>Thank you for your order! We will call you shortly</b>';
 		</script>
 	</head>

+ 10 - 2
modules/module_shop_act_order.go

@@ -57,16 +57,24 @@ func (this *Modules) RegisterAction_ShopOrder() *Action {
 			}
 		}
 		if (*wrap.Config).Shop.Orders.RequiredFields.MobilePhone != 0 {
-			if strings.TrimSpace(pf_client_phone) == "" || !utils.IsValidMobile(pf_client_phone) {
+			if strings.TrimSpace(pf_client_phone) == "" {
 				wrap.Write(`{"error": true, "field": "client_phone", "variable": "ShopOrderEmptyMobilePhone"}`)
 				return
 			}
+			if !utils.IsValidMobile(pf_client_phone) {
+				wrap.Write(`{"error": true, "field": "client_phone", "variable": "ShopOrderNotCorrectMobilePhone"}`)
+				return
+			}
 		}
 		if (*wrap.Config).Shop.Orders.RequiredFields.EmailAddress != 0 {
-			if strings.TrimSpace(pf_client_email) == "" || !utils.IsValidEmail(pf_client_email) {
+			if strings.TrimSpace(pf_client_email) == "" {
 				wrap.Write(`{"error": true, "field": "client_email", "variable": "ShopOrderEmptyEmailAddress"}`)
 				return
 			}
+			if !utils.IsValidEmail(pf_client_email) {
+				wrap.Write(`{"error": true, "field": "client_email", "variable": "ShopOrderNotCorrectEmailAddress"}`)
+				return
+			}
 		}
 		if (*wrap.Config).Shop.Orders.RequiredFields.Delivery != 0 {
 			if strings.TrimSpace(pf_client_delivery_comment) == "" {