I think the problem is that you just get the product from the lineItem.Sku not the variant.
Try using lineItem.VariantSku to get the variant. If that fails maybe the lineItem isn't a variant at all. You can check that with "product.IsVariant".
I am trying to get at the variant description so that website users can see what they have added to the cart. I have trie your above code however variant doesnt have longdecription as an option. The screen grab below shows the text that I am trying to display in the cart.
Get variant description in order line
I want to dispay the variant description of the item added to my cart.
I have the following code:
@foreach (var lineItem in basket.OrderLines)
{
var product = @CatalogLibrary.GetProduct(lineItem.Sku);
<span class="options">
@product.GetDescription(cultureCode).LongDescription;
</span>
}
This gives me the product description and not the description of the variant.
Anyone?
Cheers,
Marc
I think the problem is that you just get the product from the lineItem.Sku not the variant.
Try using lineItem.VariantSku to get the variant. If that fails maybe the lineItem isn't a variant at all. You can check that with "product.IsVariant".
I tried:
var product = @CatalogLibrary.GetProduct(lineItem.VariantSKU);
Which gives me 'The product with SKU does not exist'
The SKU returned is 001 which is the correct SKU for my variant
The full SKU IS 'PR001 - 001' SO I tried:
var product = @CatalogLibrary.GetProduct(lineItem.Sku + " - " + lineItem.VariantSKU);
However also results in 'The product with SKU does not exist'
Hi Marc,
You can only load the full product with every variant like so:
Hope this helps.
Hi Soren,
I am trying to get at the variant description so that website users can see what they have added to the cart. I have trie your above code however variant doesnt have longdecription as an option. The screen grab below shows the text that I am trying to display in the cart.
Cheers,
Marc
The product/variant itself hasn't the LongDescription.
The Descriptions are in the ProductDescriptions property of the product. So you have to get the description and than the long description.
ProductDescription pd = variant.GetDescription(culture.ToString()); and than pd.LongDescription where culture is the current culture.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.