Fix email validation before submitting checkout details
This commit is contained in:
parent
faa62bb9ad
commit
b4990cbe21
@ -298,7 +298,7 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
|
|||||||
city: _txtBillingCity.text,
|
city: _txtBillingCity.text,
|
||||||
postalCode: _txtBillingPostalCode.text,
|
postalCode: _txtBillingPostalCode.text,
|
||||||
phoneNumber: _txtBillingPhoneNumber.text,
|
phoneNumber: _txtBillingPhoneNumber.text,
|
||||||
emailAddress: _txtBillingEmailAddress.text,
|
emailAddress: _txtBillingEmailAddress.text.trim(),
|
||||||
customerCountry: _billingCountry,
|
customerCountry: _billingCountry,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -314,7 +314,7 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
|
|||||||
addressLine: _txtShippingAddressLine.text,
|
addressLine: _txtShippingAddressLine.text,
|
||||||
city: _txtShippingCity.text,
|
city: _txtShippingCity.text,
|
||||||
postalCode: _txtShippingPostalCode.text,
|
postalCode: _txtShippingPostalCode.text,
|
||||||
emailAddress: _txtShippingEmailAddress.text,
|
emailAddress: _txtShippingEmailAddress.text.trim(),
|
||||||
customerCountry: _shippingCountry);
|
customerCountry: _shippingCountry);
|
||||||
|
|
||||||
if (customerShippingAddress.hasMissingFields()) {
|
if (customerShippingAddress.hasMissingFields()) {
|
||||||
@ -328,32 +328,33 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Email validation
|
|
||||||
String billingEmail = _txtBillingEmailAddress.text;
|
|
||||||
String shippingEmail = _txtShippingEmailAddress.text;
|
|
||||||
if (billingEmail.isNotEmpty && !validate.isEmail(billingEmail)) {
|
|
||||||
showToastNotification(
|
|
||||||
context,
|
|
||||||
title: trans("Oops"),
|
|
||||||
description: trans("Please enter a valid billing email"),
|
|
||||||
style: ToastNotificationStyleType.WARNING,
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shippingEmail.isNotEmpty && !validate.isEmail(shippingEmail)) {
|
|
||||||
showToastNotification(
|
|
||||||
context,
|
|
||||||
title: trans("Oops"),
|
|
||||||
description: trans("Please enter a valid shipping email"),
|
|
||||||
style: ToastNotificationStyleType.WARNING,
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckoutSession.getInstance.billingDetails!.shippingAddress =
|
CheckoutSession.getInstance.billingDetails!.shippingAddress =
|
||||||
customerShippingAddress;
|
customerShippingAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Email validation
|
||||||
|
String billingEmail = CheckoutSession.getInstance.billingDetails!.billingAddress!.emailAddress!;
|
||||||
|
String shippingEmail = CheckoutSession.getInstance.billingDetails!.shippingAddress!.emailAddress!;
|
||||||
|
// Billing email is required for Stripe
|
||||||
|
if (billingEmail.isEmpty || !validate.isEmail(billingEmail)) {
|
||||||
|
showToastNotification(
|
||||||
|
context,
|
||||||
|
title: trans("Oops"),
|
||||||
|
description: trans("Please enter a valid billing email"),
|
||||||
|
style: ToastNotificationStyleType.WARNING,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shippingEmail.isNotEmpty && !validate.isEmail(shippingEmail)) {
|
||||||
|
showToastNotification(
|
||||||
|
context,
|
||||||
|
title: trans("Oops"),
|
||||||
|
description: trans("Please enter a valid shipping email"),
|
||||||
|
style: ToastNotificationStyleType.WARNING,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (valRememberDetails == true) {
|
if (valRememberDetails == true) {
|
||||||
await CheckoutSession.getInstance.saveBillingAddress();
|
await CheckoutSession.getInstance.saveBillingAddress();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user