BasketItemDataSource.CreateForProduct Returning Null?
Posted: Fri Nov 18, 2011 12:31 pm
We have a gift card on one of our websites. It is set up as follows:
I tracked down the error and it is occurring in the GetBasketItem() function of the BuyProductDialog.ascx.cs file. It occurs because BasketItemDataSource.CreateForProduct returns null for the product when set up as mentioned above. Unfortunately, the next line of code is basketItem.BasketId = basket.BasketId (which throws the null reference error because basketItem is null so it has no BasketId property).
Any ideas on how best to handle this situation?
- Visibility = Hidden (so it doesn't show up in search or in site categories)
- Max Quantity = 1 (only 1 per order)
- Product Template Includes 1 Customer TextBox Field for inputing gift message
I tracked down the error and it is occurring in the GetBasketItem() function of the BuyProductDialog.ascx.cs file. It occurs because BasketItemDataSource.CreateForProduct returns null for the product when set up as mentioned above. Unfortunately, the next line of code is basketItem.BasketId = basket.BasketId (which throws the null reference error because basketItem is null so it has no BasketId property).
Any ideas on how best to handle this situation?