available start and end dates

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 năm cách đây
Hi,

Could someone please clarify how  the "Available End Date" on the product variant special prices Nop 2.3 behaves.

if the end date is suppose 7/30/2012, i would expect it to run all day on the 7/30 and expire on 7/31 when its no longer the end date which was set to 7/30/2012

i tried setting up the variant to test it and the behavior is that it doesnt show up on the "end date" which is 7/30 in this example, it expires on 7/29/2012 midnight before it hits 7/30

*argh, could i be any more confusing*


i believe this is the code thats doing it, Nop 2.3/Services/Catalog/ProductService.cs

public virtual IList<ProductVariant> GetProductVariantsByProductId(int productId, bool showHidden = false)
{
//......//

   if (!showHidden)
                {
                    //The function 'CurrentUtcDateTime' is not supported by SQL Server Compact.
                    //That's why we pass the date value
                    var nowUtc = DateTime.UtcNow;
                    query = query.Where(pv =>
                            !pv.AvailableStartDateTimeUtc.HasValue ||
                            pv.AvailableStartDateTimeUtc <= nowUtc);
                    query = query.Where(pv =>
                            !pv.AvailableEndDateTimeUtc.HasValue ||
                            pv.AvailableEndDateTimeUtc >= nowUtc);
                }

//......//
}


which looks like to me, that the product variant should be available including the end date

StartDate <= nowUtc <= EndDate

but it doesn't behave like that
11 năm cách đây
DateTimes in C# have a time of 12:00 AM unless specified.  Since the admin control doesn't let you specify a time, you should either type in 1 day later or change the code to append  .AddDays(1) to the end of the End Date.
11 năm cách đây
Ohh i see whats happening!

Thanks Andy! I ll use adddays and run some tests, make sure it doesnt throw off the counting days calculations
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.