Developer forum

Forum » Ecommerce - Standard features » How to show variant in the Cart

How to show variant in the Cart

Sonni Tost
Reply

Hi there,

I am a bit new to the Dynamicweb eCommerce so forgive me if the question is a bit basic.

Anyway - I have a customer who wants to show the products along with the selected variants in the cart.

I have added Variants in the Management center. I have added the variants to the products. But when i add a product in a selected variant (fx. the colour green) to the cart i cannot see the the selected variant in the Cart.

I am using the provided template with the code below:

<td nowrap>
    <a href="<!--@Ecom:Order:OrderLine.ProductLink-->">
        <!--@Ecom:Order:OrderLine.ProductName.Short-->
        <!--@If Defined(Ecom:Order:OrderLine.ProductVariantText)-->
            (<!--@Ecom:Order:OrderLine.ProductVariantText-->)
        <!--@EndIf(Ecom:Order:OrderLine.ProductVariantText)-->
    </a>
</td>

But it does not show the ProductVariantText.

Can anybody point me in the right direction?

Kind regards

 

Sonni T.


Replies

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

Hi Sonni

You have to make sure you add the variant to the cart. So the variantid needs to be submitted along with the product id when you commit the cmd=addtocart. So your addtocart command would look something like this:

<form name="PROD75" id="PROD75" method="get" action="/Default.aspx">
<input type="hidden" name="ProductURL" id="ProductURL" value="" />
<input type="hidden" name="CartCmd" id="CartCmd" value="add" />
<input type="hidden" name="ProductID" id="ProductID" value="PROD75" />
<input type="hidden" name="VariantID" id="VariantID" value="VO1.VO6" />
<input type="hidden" name="UnitID" id="UnitID" value="" />
<input type="hidden" name="wishListID" id="wishListID" value="0" />

<input type="submit" name="add to cart">
</form>

In the template do something like this:

<form name="<!--@Ecom:Product.ID-->" id="<!--@Ecom:Product.ID-->" method="get" action="/Default.aspx">
<!--@Ecom:Product.Form.Clean-->
 
<h3><!--@Ecom:Product.Name--> <!--@Ecom:Product.SelectedVariantComboName--></h3>
    
<!--@LoopStart(VariantCombinations)-->
<!--@HeaderStart-->
<div id="productvariants">
 <select id="<!--@Ecom:VariantGroup.ID-->" name="<!--@Ecom:VariantGroup.Name-->" onchange="setVariant(this.options[this.selectedIndex].value);">
  <option>Select variant</option>
  <!--@HeaderEnd-->
  <option value="/<!--@Ecom:VariantCombination.LinkGroup.Clean-->"
   <!--@If Defined(Ecom:VariantCombination.Selected)--> selected="selected"<!--@EndIf(Ecom:VariantCombination.Selected)-->>
   <!--@Ecom:VariantCombination.VariantText-->
  </option>
  <!--@FooterStart-->
 </select>
</div>
<br />
<!--@FooterEnd-->
<!--@LoopEnd(VariantCombinations)-->

<strong><!--@Ecom:Product.Discount.Price--></strong>

<input type="number" name="Quantity" value="1" style="width:60px; text-align:center; margin-right:5px; height:34px;">
<button type="submit" name="submit" class="btn btn-two">Add to cart</button>

    
</form>

See the eCommerce book chapter on adding products to cart.

Nicolai

Votes for this answer: 1
 
Sonni Tost
Reply

Hi Nicolai,

Thank you! The template used a add-to-cart-link and not a button that submitted the cart including the variants.

Now it works!

Sonni T.

 

You must be logged in to post in the forum