Displaying variant prices on category list page

Store UI, layout, design, look and feel; Discussion on the customer facing pages of your online store. Cascading Style Sheets, Themes, Scriptlets, NVelocity and the components in the ConLib directory.
Post Reply
Will
Captain (CAPT)
Captain (CAPT)
Posts: 263
Joined: Fri Oct 05, 2007 8:02 am

Displaying variant prices on category list page

Post by Will » Thu May 22, 2008 11:45 am

Is there a way to display the prices for all of a product's variants on the category list page?

So it would look like:

Product Name
Product Price
Variant Price

Thanks.

User avatar
m_plugables
Commander (CMDR)
Commander (CMDR)
Posts: 149
Joined: Tue Mar 11, 2008 12:44 am
Contact:

Re: Displaying variant prices on category list page

Post by m_plugables » Tue May 27, 2008 12:31 pm

This code may help you.

Edit the ConLib/CategoryListPage.ascx.cs file and add the following method to it

Code: Select all

public string GetVariantPrices(Object productId) 
    {

        ProductVariantCollection variants = ProductVariantDataSource.LoadForProduct(AlwaysConvert.ToInt(productId));
        StringBuilder result = new StringBuilder();
        foreach(ProductVariant pv in variants)
        {
            result.Append(pv.Price.ToString("ulc"));
            result.Append(",");
        }
        if (result.Length > 0)
            result.Remove((result.Length - 1), 1);
        return result.ToString();
    }
Now edit the ConLib/CategoryListPage.ascx file and search the CatalogNodeList repeater control and replace with the following code

Code: Select all

<asp:Repeater ID="CatalogNodeList" runat="server" OnItemDataBound="CatalogNodeList_ItemDataBound" EnableViewState="false">                    
                    <HeaderTemplate>
                        <table  class="pagedList" style="width: 100%;" border="0" cellspacing="1">
                            <tr>
				                <th scope="col" align="left">SKU</th>
				                <th scope="col">Name</th>
				                <th scope="col">Manufacturer</th>
				                <th scope="col" style="width: 80px;" align="center">Retail&nbsp;Price</th>
				                <th scope="col" align="center">Our&nbsp;Price</th>
				                <th scope="col" align="center">Our&nbsp;Variant Prices</th>
				                <th scope="col">&nbsp;</th>
			                </tr>
                    </HeaderTemplate>
                    <ItemTemplate>                       
                        <asp:PlaceHolder ID="phItemTemplate1" runat="server"></asp:PlaceHolder>
                        <td align='center'><uc:ProductPrice ID="Price" runat="server" Product='<%#Eval("ChildObject")%>' /></td>
                        <td><asp:Label ID="albl" runat="server" Text='<%# GetVariantPrices(Eval("CatalogNodeId")) %>' ></asp:Label> </a </td>
                        <td><uc:AddToCartLink ID="Add2Cart" runat="server" Product='<%#((CatalogNode)Container.DataItem).CatalogNodeType == CatalogNodeType.Product?((CatalogNode)Container.DataItem).ChildObject:null%>' /></td>
                        <asp:PlaceHolder ID="phItemTemplate2" runat="server"></asp:PlaceHolder>
                        
                    </ItemTemplate>
                    
                    <FooterTemplate>
                        </table>
                    </FooterTemplate>
                </asp:Repeater>
                <asp:PlaceHolder ID="PagerPanel" runat="server">
                    <div class="paging">
                        <asp:Repeater ID="PagerControls" runat="server" OnItemCommand="PagerControls_ItemCommand" EnableViewState="true">
                            <ItemTemplate>
                                <asp:LinkButton ID="PageLink" runat="server" Text='<%#Eval("Text")%>' CommandName="Page" CommandArgument='<%#Eval("PageIndex")%>' Enabled='<%#Eval("Enabled")%>'></asp:LinkButton>
                            </ItemTemplate>
                        </asp:Repeater>
Now you will see and extra column containing the Variant prices when you refresh the page.
Image
Visit the links below to Download Plugins for your AC7 Store
http://www.plugables.com
http://blog.plugables.com

Post Reply