Hi Dynamicweb,
In our solution we rely on a lot of information on the current cart which depends on the OrderContext, but we have an issue getting access to the different carts based on the OrderContext.
The only way to get access to the ordercontext (as I see it) is by setting the CartContext property in context.vb. The set-part in the property is however not public...
Public Shared Property CartContext As OrderContext
Get
'Get context if it has been set explicitly
Dim contextCandidate As Object = HttpContext.Current.Items(_customCartContextSessionKey)
If contextCandidate IsNot Nothing Then
Return DirectCast(contextCandidate, OrderContext)
End If
'Get context from Request
Dim context As OrderContext = Nothing
Try
'Try-catch because of the unpredictable behavior of HttpContext.Current.Request
context = OrderContext.GetOrderContextById(Input.Request(OrderContext.OrderContextRequestName))
Catch ex As Exception
End Try
'Get default context for the current shop
If context Is Nothing Then
Dim pageview As Dynamicweb.Frontend.PageView = Dynamicweb.Frontend.PageView.Current
If pageview IsNot Nothing AndAlso pageview.Area IsNot Nothing Then
Dim area As Dynamicweb.Content.Area = If(Dynamicweb.Content.Area.GetAreaById(pageview.Area.ID), New Content.Area())
Dim shop As Shops.Shop = Application.Shop(area.EcomShopID)
If shop IsNot Nothing Then
context = OrderContext.GetOrderContextById(shop.OrderContextID)
End If
End If
End If
'Return the context. If no context was found, Nothing is returned indicating that we fall back to the global cart.
Return context
End Get
Friend Set(value As OrderContext)
HttpContext.Current.Items(_customCartContextSessionKey) = value
End Set
End Property
So what to do? :-)
Best regards, Anders