How to make required fields unnecessary? Disable field validation?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 года назад
hi
we have nopcommerce 3.90

i use guest checkout and I want to disable some required fields in billing address

i found this code in \Views\Shared\_CreateOrUpdateAddress.cshtml

@if (Model.CountryEnabled)
    {
        <div class="inputs">
            @Html.LabelFor(model => model.CountryId, new { }, ":")
                @Html.DropDownListFor(model => model.CountryId, Model.AvailableCountries)
            @Html.RequiredHint()
            @Html.ValidationMessageFor(model => model.CountryId)
        </div>
    }
@if (Model.ZipPostalCodeEnabled)
    {
        <div class="inputs">
            @Html.LabelFor(model => model.ZipPostalCode, new { }, ":")
                @Html.EditorFor(model => model.ZipPostalCode)
            @if (Model.ZipPostalCodeRequired)
            {
                @Html.RequiredHint()
            }
            @Html.ValidationMessageFor(model => model.ZipPostalCode)
        </div>
    }


is there any code to disable required fields? i mean disable field validation

PS: I know that I can disable it in admin panel, but I need to do it in code... or I need to disable in admin panel, but show them in shipping address
3 года назад
Helll arthur_shneider
You have to do customization in the code and che the condition if customer is guest then  you have to skip your required field validation.
_workcontext.currentcustomer.Isguest() this with you get customer is registered or guest customer.
3 года назад
SagarKayasth wrote:
Helll arthur_shneider
You have to do customization in the code and che the condition if customer is guest then  you have to skip your required field validation.
_workcontext.currentcustomer.Isguest() this with you get customer is registered or guest customer.


Thank you so much for your reply.

Can you please point where do I need to insert this code in order to skip the fields?
3 года назад
Can someone help, please?

How can I make skip those fields?
3 года назад
You have to write condition in validator class.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.