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.

  • Rob Smith 34 posts 165 karma points
    Sep 25, 2013 @ 16:27
    Rob Smith
    0

    How would I list all variants with an add to cart button

    Hi I am new to uCommerce and have the Razor demo store which I am using as a basis.

    What I want to achieve is a simple table listing all of the variants available with the price and an 'add to cart' button next to each variant which I though would be simple enough!

    Can anybody point me in the right direction?

  • Søren Spelling Lund 1797 posts 2786 karma points
    Sep 25, 2013 @ 21:21
    Søren Spelling Lund
    101

    You can do a foreach over the variants in the product on the page and render the relevant button next to each:

    var catalog = SiteContext.Current.CatalogContext.CurrentCatalog;
    <table>
    foreach (var variant in product.Variants)
    {
    var price = CatalogLibrary.CalculatePrice(product, catalog);
    <tr>
    <td>@variant.Sku</td>
    <td>@price.YourPrice.Amount</td>
    </tr>
    }
    </table> 
Please Sign in or register to post replies

Write your reply to:

Draft