Show add cart and price in homepage

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 anos atrás
I tried to look for a place that where I can edit to show " add to cart and price in homepage". I don't know where to look and how to edit it. Any help would be appreciated. Thank you!
14 anos atrás
I'm not sure if there is an officially supported method, but this is something I actually looked at last night for a website I am setting up using nopcommerce.

I was shocked that this isn't in the product by default, the only reason that I can see and that makes it a little tricky is that the product may have variants and/or attributes.

I modified the website code to include the product variants in grid module within the home page products module and restricted the number of variants displayed to one and it works quite neatly.

The product variants in grid looks at the query string if I remember correctly for its product id so it was just a matter of passing this through to the control.

Due to the nature of the website I removed the add to cart button and replaced it with a more info button, but I did have it working.

If you are a developer and happy to modify the code I can post the modifications later as I am at a different computer.
14 anos atrás
Hi, I did that changing the HomePageProducts page

<%@ Control Language="C#" AutoEventWireup="true"
    Inherits="NopSolutions.NopCommerce.Web.Modules.HomePageProductsControl" Codebehind="HomePageProducts.ascx.cs" %>
<%@ Register TagPrefix="nopCommerce" TagName="ProductBox3" Src="~/Modules/ProductBox3.ascx" %>
  
<div class="HomePageProductGrid">
    <asp:DataList ID="dlCatalog" runat="server" RepeatColumns="3" RepeatDirection="Horizontal"
        RepeatLayout="Table" OnItemDataBound="dlRelatedProducts_ItemDataBound" ItemStyle-CssClass="ItemBox">
        <ItemTemplate>
            <nopCommerce:ProductBox3 ID="ctrlProductBox" Product='<%# Container.DataItem %>' runat="server" />
       </ItemTemplate>
    </asp:DataList>
</div>


        protected void dlRelatedProducts_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Product product = e.Item.DataItem as Product;
                if (product != null)
                {
                    string productURL = SEOHelper.GetProductURL(product);

                    HyperLink hlImageLink = e.Item.FindControl("hlImageLink") as HyperLink;
                    if (hlImageLink != null)
                    {
                        ProductPictureCollection productPictures = product.ProductPictures;
                        if (productPictures.Count > 0)
                            hlImageLink.ImageUrl = PictureManager.GetPictureUrl(productPictures[0].Picture, SettingManager.GetSettingValueInteger("Media.Product.ThumbnailImageSize", 125), true);
                        else
                            hlImageLink.ImageUrl = PictureManager.GetDefaultPictureUrl(SettingManager.GetSettingValueInteger("Media.Product.ThumbnailImageSize", 125));

                        hlImageLink.NavigateUrl = productURL;
                        hlImageLink.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageLinkTitleFormat"), product.Name);
                        hlImageLink.Text = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name);
                    }

                    HyperLink hlProduct = e.Item.FindControl("hlProduct") as HyperLink;
                    if (hlProduct != null)
                    {
                        hlProduct.NavigateUrl = productURL;
                        hlProduct.Text = Server.HtmlEncode(product.Name);
                    }
                }
            }
        }
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.