Open Modules\ProductAttributes.ascx.cs file and replace
case AttributeControlTypeEnum.Datepicker: { var datePicker = new NopDatePicker(); //changes these properties in order to change year range datePicker.FirstYear = DateTime.Now.Year; datePicker.LastYear = DateTime.Now.Year + 1; datePicker.ID = controlId; divAttribute.Controls.Add(datePicker); }
with the following code:
case AttributeControlTypeEnum.Datepicker: { var datePicker = new NopDatePicker(); //changes these properties in order to change year range datePicker.FirstYear = YourStartYearHere; datePicker.LastYear = YourEndYearHere; datePicker.ID = controlId; divAttribute.Controls.Add(datePicker); }
Open Modules\ProductAttributes.ascx.cs file and replace
case AttributeControlTypeEnum.Datepicker: { var datePicker = new NopDatePicker(); //changes these properties in order to change year range datePicker.FirstYear = DateTime.Now.Year; datePicker.LastYear = DateTime.Now.Year + 1; datePicker.ID = controlId; divAttribute.Controls.Add(datePicker); }
with the following code:
case AttributeControlTypeEnum.Datepicker: { var datePicker = new NopDatePicker(); //changes these properties in order to change year range datePicker.FirstYear = YourStartYearHere; datePicker.LastYear = YourEndYearHere; datePicker.ID = controlId; divAttribute.Controls.Add(datePicker); }
and sir i want only future date i mean the how can i prevent that customer can not select any past date . tell me the code fr that.
Also modify Nop.Web.Framework.TagHelpers.Shared : NopDatePickerTagHelper
But previous month and days past is a little harder - I mean they are all still in the list just ordered differently ?
Otherwise you can check the date after entered and display and error if it is in the future
But sure what date you want to future proof ?
Sir i am using 3.8 version and i given a product attribute with the name of chose delivery date with date picker id now i want customer or buyer can only chose a future a date for delivery show how can i add this condition and provide me code and the name of file in which i have to add that code.
//other attribute controle types does not have validation return false; }
2. Check the date is in the future
Edit public partial class ShoppingCartService : IShoppingCartService
In public virtual IList<string> GetShoppingCartItemAttributeWarnings(Customer customer,
Under //validation rules
Change
}
if (warnings.Any()) return warnings;
To
//Datepicker if (pam.AttributeControlType == AttributeControlType.Datepicker) { var valuesStr = _productAttributeParser.ParseValues(attributesXml, pam.Id); var enteredDate = valuesStr.FirstOrDefault(); var convertedDate = DateTime.Parse(enteredDate); var convertedDateUtc = DateTime.SpecifyKind(convertedDate, DateTimeKind.Utc); var now = DateTime.UtcNow; if (convertedDateUtc.CompareTo(now) <= 0) warnings.Add(_localizationService.GetResource("Products.ProductAttributes.DateInFuture")); } }
if (warnings.Any()) return warnings;
3. Create a LocalResourceString
Products.ProductAttributes.DateInFuture "Please enter a date in the future"
//other attribute controle types does not have validation return false; }
2. Check the date is in the future
Edit public partial class ShoppingCartService : IShoppingCartService
In public virtual IList<string> GetShoppingCartItemAttributeWarnings(Customer customer,
Under //validation rules
Change
}
if (warnings.Any()) return warnings;
To
//Datepicker if (pam.AttributeControlType == AttributeControlType.Datepicker) { var valuesStr = _productAttributeParser.ParseValues(attributesXml, pam.Id); var enteredDate = valuesStr.FirstOrDefault(); var convertedDate = DateTime.Parse(enteredDate); var convertedDateUtc = DateTime.SpecifyKind(convertedDate, DateTimeKind.Utc); var now = DateTime.UtcNow; if (convertedDateUtc.CompareTo(now) <= 0) warnings.Add(_localizationService.GetResource("Products.ProductAttributes.DateInFuture")); } }
if (warnings.Any()) return warnings;
3. Create a LocalResourceString
Products.ProductAttributes.DateInFuture "Please enter a date in the future"