I'm working on a site that is using volume discounts rather heavily. A new requirement I have is to add start/end dates to the discounts.
Unless I'm mistaken, AC doesn't have support for this. I've added a custom table to the data model to store a date range linked to a VolumeDiscountId. As far as display is concerned, I can conditionally show/hide discounts based on these custom fields. However, the discount is still applied to the basket by the Recalculate() method. I'm not sure that I can override that.
Has anyone ever attempted to integrate dates with discounts before? At this point, I'm considering handling it outside of AbleCommerce with a scheduled task that runs against the database on a regular basis. I suppose I could toggle the StoreId of the VolumeDiscount record to a dummy StoreId to inactivate it and then switch it back to the live StoreId to re-enable it.
P.S. We are using Specials, which supports dates, for the non-volume based deals.
volume Discounts, implementing start and end dates
Re: volume Discounts, implementing start and end dates
What about trying this...
After the recalculate is run, trying cycling through all the basket items, and checking to see if a discount exists, and if so, leave it in place or remove it based on the rules you setup.
like...
foreach(BasketItem bi in Token.User.Basket.Items)
{
if (bi.OrderItemType.Equals(OrderItemType.Discount))
{
....perform your checks here, to determine if discount is valid
}
}
We do something similar with our shipping methods.
Scott
After the recalculate is run, trying cycling through all the basket items, and checking to see if a discount exists, and if so, leave it in place or remove it based on the rules you setup.
like...
foreach(BasketItem bi in Token.User.Basket.Items)
{
if (bi.OrderItemType.Equals(OrderItemType.Discount))
{
....perform your checks here, to determine if discount is valid
}
}
We do something similar with our shipping methods.
Scott
Re: volume Discounts, implementing start and end dates
heinscott wrote:What about trying this...
Thanks, that helped a lot. I created a static method in a helper class that runs through the logic and performs the validation checks. There were a few different controls that were making calls to Basket.Recalculate(). I had to make sure to call this new discount validation method after each Recalculate() call and then everything looked good.