Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Marc Love (uSkinned.net) 445 posts 1787 karma points
    Dec 20, 2012 @ 16:02
    Marc Love (uSkinned.net)
    0

    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

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Dec 20, 2012 @ 17:21
    David Brendel
    0

    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".

  • Marc Love (uSkinned.net) 445 posts 1787 karma points
    Dec 20, 2012 @ 18:20
    Marc Love (uSkinned.net)
    0

    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'

  • Søren Spelling Lund 1797 posts 2786 karma points
    Dec 21, 2012 @ 13:35
    Søren Spelling Lund
    0

    Hi Marc,

    You can only load the full product with every variant like so:

    var product = @CatalogLibrary.GetProduct(lineItem.Sku);
    var variant = product.Variants.Single(x => x.VariantSku == lineItem.VariantSku); 

    Hope this helps.

  • Marc Love (uSkinned.net) 445 posts 1787 karma points
    Dec 21, 2012 @ 15:39
    Marc Love (uSkinned.net)
    0

    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

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Dec 24, 2012 @ 16:00
    David Brendel
    1

    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.

Please Sign in or register to post replies

Write your reply to:

Draft