Developer forum

Forum » CMS - Standard features » Using CartViewModel with 'Shopping cart': Unable to render view model template because no view model has been set.

Using CartViewModel with 'Shopping cart': Unable to render view model template because no view model has been set.

Roald Haahr Jensen
Reply

Hi,

 

Using 9.7.2, we are trying to render a 'Shopping cart' step inheriting from Dynamicweb.Frontend.CartViewModel. However, leading the template with

@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.CartViewModel>

will result in the following error:

Error executing template "Designs/Site/eCom7/CartV2/Step/CartOrderLines.cshtml"
System.InvalidOperationException: Unable to render view model template because no view model has been set.
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

 

Is this the view model to use or is there another one that works?

 

Our workaround was to make a new page template inheriting from Dynamicweb.Frontend.PageViewModel, as that one has the CartViewModel available in Model.Cart, which we can then use to work our magic. With this approach, however, there is no 'Shopping cart' app to provide us with a flow.

 

Best regards,
Roald, Novicell


Replies

 
Nicolai Pedersen
Reply

Shopping cart step templates do not support the CartViewmodel - it is only valid in the context of a pageviewmodel...

Sorry about the inconvenience.

BR Nicolai

 
Roald Haahr Jensen
Reply

Hi Nicolai,

In that case, let me put it down as a feature request.

In order to keep a consistent way of developing our templates, I would like to an app available along the lines of 'Shopping cart for view model', just like the 'Product catalogue for view model'-app, where I can inherit from Dynamicweb.Ecommerce.ProductCatalog.ProductListViewModel.

Best regards,
Roald

 
Nicolai Pedersen
Reply

Yes, we would like that too! It is a big task though, but it is on our radar!

 
Roald Haahr Jensen
Reply

That's good to know! Are there any plans as to when this will be implemented?

 
Nicolai Pedersen
Reply

Currently not. The cart app is relatively complex, and right now we have other priorities.

But a rewrite of all cart features, i.e. cartcatch (all cart operations), the cart app and support for webapi is high on our todo list. But it will not be before 9.8

 

You must be logged in to post in the forum