Developer forum

Forum » Swift » Adding a Add to Cart button in Swift_ProductListGridView.cshtml

Adding a Add to Cart button in Swift_ProductListGridView.cshtml

Justin Sjouw Dynamicweb Employee
Justin Sjouw
Reply

Hi,

I'm trying to add a add to basket button on the Swift_ProductListGridView.cshtml (I know, bad idea performance wise, but as we all know sometimes Customer is king :-))

The button works and adds the right quantiry of products to the basket.

However then the page reloads and the Facet template generates an error.

I suspect i must change something in the form definition/url parameter, but I'm not sure what and how to do that.

The url parameter is defined as: string url = Dynamicweb.Context.Current.Request.RawUrl;

The form is defined as:

<form method="post" action="@url" class="flex-fill">
<input type="hidden" name="redirect" value="false" />
<input type="hidden" name="ProductId" value="@product.Id" />
  <input type="hidden" name="cartcmd" value="add" />
 
After cliking the add cart button the error is:

Error executing template "Designs/Swift/Paragraph/Swift_ProductListFacets.cshtml"
System.ArgumentNullException: Waarde kan niet null zijn.
Parameternaam: source
   bij System.Linq.Enumerable.Count[TSource](IEnumerable`1 source)
   bij CompiledRazorTemplates.Dynamic.RazorEngine_eb1ebecab243494d97e99fea58e1f62b.&lt;&gt;c__DisplayClass0_0.&lt;RenderForm&gt;b__0(TextWriter __razor_helper_writer) in C:\DWProjects\Solutions\Melgers\Solution\Files\Swift\Files\Templates\Designs\Swift\Paragraph\Swift_ProductListFacets.cshtml:regel 225
   bij CompiledRazorTemplates.Dynamic.RazorEngine_eb1ebecab243494d97e99fea58e1f62b.Execute() in C:\DWProjects\Solutions\Melgers\Solution\Files\Swift\Files\Templates\Designs\Swift\Paragraph\Swift_ProductListFacets.cshtml:regel 75
   bij RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   bij RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   bij RazorEngine.Templating.RazorEngineServiceExtensions.&lt;&gt;c__DisplayClass16_0.&lt;RunCompile&gt;b__0(TextWriter writer)
   bij RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   bij Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   bij Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   bij Dynamicweb.Rendering.Template.RenderRazorTemplate()

 


Replies

 
Justin Sjouw Dynamicweb Employee
Justin Sjouw
Reply

Hello,

Nevermind this thread, I will use the Product List View instead!

Justin

 
Nicolai Pedersen
Reply

Hi Justin

Customer might be king, but they are also not ecommerce specialists. They might feel they need a feature because they think it is good. But often it is bad because it will decrease conversions and cause them a loss of money. I have not met a lot of customer that likes that... When explaining with known facts what is good ideas and what is bad ideas from a UX and conversion rate perspective (and not feelings) it usually is explainable.

But glad you found a solution.

BR Nicolai

 

You must be logged in to post in the forum