+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / add-to-cart for product

add-to-cart for product

19 posts, 0 answered
  1. Majid
    Majid avatar
    17 posts
    Registered:
    02 Jun 2011
    10 Oct 2011
    Link to this post
    Hi,
    I have a custom product list! I need to have "Add to cart" button for each product, but I dont know how

    thanks 
  2. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    12 Oct 2011
    Link to this post
    Hello Majid,

     ECommerce is a new module and it is still not very customizable. You can add the button to the List template of all products, but it wouldn't work because right now the productID cannot be resolved unless you have navigated to the details page of a selected product. This said, for now you will have to click on a product (to open the detail page) and then add the product to your cart. 

    All the best,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Majid
    Majid avatar
    17 posts
    Registered:
    02 Jun 2011
    13 Oct 2011
    Link to this post
    Hi Svetoslav Petsov,
    I have exactly the problem you refered! I have a button in product List view and after clicking on, It says productId is null, but in Detail view it's ok!
    I hope we have it in new SP!

    Thanks for your reply
    Majid
  4. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    13 Oct 2011
    Link to this post
    Hello Majid,

     This feature is logged into our system and is now on our roadmap. However, we currently have a lot of features that are set up for our next release (4.3), so this will be released as an option a little further in time (possibly in our 4.4 release).

    Regards,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    25 Oct 2011
    Link to this post
    Is it possible when you override the default ProductsFrontendMaster view with a custom one? Can we then use the ProductID?

    Regards,
    Daniel
  6. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    27 Oct 2011
    Link to this post
    Hello Daniel,

     Editing the templates wouldn't solve the ID problem. The only way would be to implement a custom control but it would have to re-implement the whole list functionality there (to change the way the productID is resolved).

    Greetings,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    27 Oct 2011
    Link to this post
    Well, that is what I mean, actually.
    Better re-implement it then offer a very limited list.

    Anyway, it would be of great help to have some sort of workflow description on how to order a product from beginning to end, through the API.

    There is no way that the default ProductList view and the ProductDetail view are going to fit for each design, and since our designs have great value to the customer, I have to re-write these controls anyway.

    Could you provide me of some workflow, or at least the methods I should use?

    Regards,
    Daniel
  8. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    31 Oct 2011
    Link to this post
    Hello Daniel,

     I'm sending you some examples on how to use the ECommerce's API to create Customers, add them Orders, create Products and so on. Please review the examples and get back to me if you have any questions.

    All the best,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    01 Nov 2011
    Link to this post
    Hi Svetoslav,

    Thanks for the update. Really helpful, since I was planning on writing an import procedure :)
    One thing I'm still like to know is how to add the 'add-to-cart' functionality through code.

    I have a custom control which shows a list of products. So I'll have to add a button to which should have an action that let's users place the product inside the basket.

    The default functionality is updating the cart automatically, but I'm wondering if this can also be achieved through the API?

    Regards,
    Daniel
  10. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    03 Nov 2011
    Link to this post
    Hello Daniel,

     You can try using the Telerik.Sitefinity.Modules.Ecommerce.Orders.Web.UI.AddToCartWidget in your template and in your code get the control and set its ProductId property to the selected product in your list (this way overriding its default functionality by getting the productId from the URL)

    Kind regards,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    08 Nov 2011
    Link to this post
    Hi Svetoslav,

    Thanks. That worked. The only problem here is that I don't like the default view of this control.
    So e.g. I don't want the textbox for the amount of items, I just want the button.

    Probably this is not possible.

    So how can I simulate this from code? What steps do I have to take to add a product to my shopping cart?

    Thanks,
    Daniel
  12. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    10 Nov 2011
    Link to this post
    Hi Daniel,

     You can always change the template of your control. What you need to do is - you need to inherit the AddToCartWidget class, change the LayoutTemplatePath property (in order to change the template). At initialize control, the Text property of the QuantityControl (that is the TextBox on the template) is always set to "1" so if you just hide that field, then its value would always be "1". Here's the default template that you can change (for example add a css property to the TextBox that hides it):

    <%@ Control Language="C#" %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %>
     
    <asp:UpdatePanel ID="UpdatePanel" runat="server">
        <ContentTemplate>
            <sf:Message runat="server" ID="addedToCartMessage" CssClass="sfMessage sfTopMsg" RemoveAfter="10000" />
        </ContentTemplate>
    </asp:UpdatePanel>
     
    <asp:Label ID="quantityLabel" runat="server" Text='<%$Resources:OrdersResources, QuantityColon %>' AssociatedControlID="quantity" CssClass="sfTxtLbl" />
    <asp:RequiredFieldValidator ID="quantityRequiredFieldValidator" runat="server"
        ControlToValidate="quantity"
        ValidationGroup="addToCart"
        Display="Dynamic"
        CssClass="sfErrorWrp">
            <span class="sfError"><asp:Literal runat="server" ID="lProductQuantityIsRequired" Text="<%$Resources:OrdersResources, ProductQuantityIsRequired %>" /></span>   
    </asp:RequiredFieldValidator>
    <asp:RangeValidator ID="quantityValidator" runat="server"
        MinimumValue="1"
        MaximumValue="9999"
        ControlToValidate="quantity"
        ValidationGroup="addToCart"
        Type="Integer"
        Display="Dynamic"
        CssClass="sfErrorWrp">
            <span class="sfError"><asp:Literal runat="server" ID="lProductQuantityIsInvalid" Text="<%$Resources: OrdersResources, ProductQuantityIsInvalid %>" /></span>   
    </asp:RangeValidator>
    <asp:TextBox ID="quantity" runat="server" CssClass="sfTxt sfQuantity" />
     
    <asp:Button ID="addToCartButton" runat="server" Text='<%$Resources:OrdersResources, AddToCart %>' ValidationGroup="addToCart" CssClass="sfAddToCartBtn" />

    All the best,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  13. Cormac
    Cormac avatar
    11 posts
    Registered:
    02 Jun 2008
    10 Jan 2012
    Link to this post
    Hi,

    Is this resolved in 4.4 version. We would like to add "buy now" button in the products list page itself.

    Best Regards,
    Cormac
  14. Venkata Koppaka
    Venkata Koppaka avatar
    67 posts
    Registered:
    24 Sep 2012
    12 Jan 2012
    Link to this post
    Hello Cormac,

    The feature is not built out of the box in Sitefinity 4.4. However you can achieve the functionality by using our API currently.
    If you wish to see the feature in action please go to http://screencast.com/t/0M9UtFwc

    For detailed steps to setup your project with the code attached to the response read below

    Here is the list of steps that you need to do

    1. Copy the CustomProductMasterView.ascx and CustomBuyNowView.ascx files to SitefinityWebApp project
    2. Now go to pages in Sitefinity Backend, open the page which has product list widget. Hit Edit->Advanced->ControlDefinition->Views->ProductsFrontEndMaster
    3. And set TemplatePath to ~/CustomProductMasterView.ascx (Setting_Template.png)
    4. Save and publish.

    Things to note in CustomProductMasterView.ascx file –

    1. We are using a BuyNow widget to perform add to cart operation. There is reason for doing so. If your product were to have any Product Variations (feature introduced in 4.4), the add to cart button on the master list does not make sense as the user of your site has to pick options before adding the product to the cart.
    2. So the BuyNow widget, decides whether to add the item to cart directly or to redirect the user product detail page where he can pick the options and add the product to cart.
    3. I added couple of lines to CustomProductMasterView.ascx which are not a part of the actual template. They are –
    <%@ Register Namespace="Telerik.Sitefinity.Modules.Ecommerce.Catalog.Web.UI.Views" Assembly="Telerik.Sitefinity" TagPrefix="sf" %>
     
    <sf:BuyNowView ID="usrBuyNowView" runat="server" ProductId= '<%# Eval("Id") %>' ProductsListPageId ="B23147EE-D087-4147-8C13-147902562DA4" CheckoutPageId="6C588951-BBFA-4C70-A983-46A41DA3B022" LayoutTemplatePath="~/CustomBuyNowView.ascx" />
    1. Please note the ProductsListPageId, CheckoutPageId properties, these are two properties that you have to change according to your project.

    Let us know if you have any further questions

    Kind regards,
    Venkata Koppaka
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  15. Bob
    Bob avatar
    25 posts
    Registered:
    14 Aug 2012
    08 Feb 2013
    Link to this post

    FYI

    http://www.sitefinity.com/blogs/steve-millers-blog/2012/04/11/sitefinity_ecommerce_ndash_combining_widgets_together_on_a_widget_template

  16. OC
    OC avatar
    129 posts
    Registered:
    17 Nov 2004
    23 Oct 2013 in reply to Bob
    Link to this post
    I've used the code on this page to create an AddToCart button, and it worked just fine up to 5.4. From 6.0 it is not working anymore, and debugging this is a nightmare.

    Has someone a working sample on how to get a add-to-cart-button in product lists? And I am NOT talking about a BUY NOW button - that is NOT the same :-)
  17. Ivan D. Dimitrov
    Ivan D. Dimitrov avatar
    310 posts
    Registered:
    26 Mar 2015
    28 Oct 2013
    Link to this post
    Hi Ole,

    Please see this video concerning the deployment and functionality of the sample. The code of the template is as follows:

    <%@ Control Language="C#" %>
    <%@ Import Namespace="Telerik.Sitefinity.Model" %>
    <%@ Import Namespace="System.ComponentModel" %>
    <%@ Import Namespace="Telerik.Sitefinity.Ecommerce.Catalog.Model" %>
    <%@ Register Assembly="Telerik.Sitefinity.Ecommerce" Namespace="Telerik.Sitefinity.Modules.Ecommerce.Orders.Web.UI"
        TagPrefix="sfOrders" %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %> 
    <%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI.Fields"
        TagPrefix="sfFields" %>
    <%@ Register TagPrefix="sfCatalog" Namespace="Telerik.Sitefinity.Modules.Ecommerce.Catalog.Web.UI.Fields" Assembly="Telerik.Sitefinity.Ecommerce"%>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.ContentUI" Assembly="Telerik.Sitefinity" %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.Comments" Assembly="Telerik.Sitefinity" %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.PublicControls.BrowseAndEdit" Assembly="Telerik.Sitefinity" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Modules.Ecommerce.Catalog.Web.UI" Assembly="Telerik.Sitefinity.Ecommerce" %>
     
    <div id="Div1" runat="server" visible="false" class="sfErrorSummary sfTopMsg">
        <asp:Label ID="Label1" runat="server" />
    </div>
     
    <asp:Placeholder id="widgetBody" runat="server">
        <div class="sfClearfix">
        <div class="sfProductsSortByWrp" id="productSortControlWrp" runat="server">
            <sf:SortProductsControl ID="sortProductsControl" runat="server" />
        </div>
         
        <sf:TotalProductsControl runat="server" ID="totalProductsControlTop" CssClass="sfCatalogTotalCount" />
     
        <sf:Pager id="topPager" runat="server" DisplayCount="3" ShowPrevAndNext="true" CssClass="sfCatalogPager" />
         
         
        <sf:ItemsPerPageSelector ID="itemsPerPageSelectorTop" runat="server" GroupingKey="Products" CssClass="sfitemsPerPageWrp" />
     
        <telerik:RadListView ID="productsListView"
                             runat="server"
                             ItemPlaceholderID="ProductContainer"
                             EnableEmbeddedSkins="false"
                             EnableEmbeddedBaseStylesheet="false">
            <LayoutTemplate>
                <ul class="sfproductsList">
                    <asp:PlaceHolder ID="ProductContainer" runat="server" />
                </ul>
            </LayoutTemplate>
            <ItemTemplate>
                <li class="sfproductListItem">
                    <div class="sfproductTmbWrp">
                        <sf:DetailsViewHyperLink ID="thumbnailLink" runat="server" ImageUrl='<%# Eval("ThumbnailUrl") %>' Text='<%# Eval("ThumbnailAlternativeText") %>' ToolTip='<%# Eval("Title") %>' />
                    </div>
                    <h2 class="sfproductTitle">
                        <sf:DetailsViewHyperLink ID="DetailsViewHyperLink1" Text='<%# (Eval("Title").ToString()).TruncateString(56, SitefinityExtensions.TruncateOptions.IncludeEllipsis) %>' runat="server" CssClass="sfproductTitleLnk" />
                    </h2>
                    <div class="sfproductPrice">
                        <sfCatalog:DisplayPriceField id="displayPriceField" ObjectType="Product" ObjectId='<%# Eval("Id") %>' runat="server" />
                    </div>
                    
                   
                 
                            <sf:ProductDynamicFields id="productDynamicFieldsControl" ProductItem='<%# Page.GetDataItem() %>' runat="server" />
             
                            
                       
                            <div class="sfproductOptions">
                                <sf:ProductOptionsControl id="productOptionsControl" ProductItem='<%# Page.GetDataItem() %>' runat="server" />
                            </div>
                            
     
                             
     
                             
                            <div class="sfAddToCartWidget">
                                <sfOrders:AddToCartWidget ID="addToCartWidget" ProductId='<%# Eval("Id") %>' runat="server" />
                            </div>
     
                             
                   
                   
                   
                   
                    <%--NOTE: Uncomment the next line to display custom product fields--%>
                    <%--<sf:ProductDynamicFields id="productDynamicFields" runat="server"></sf:ProductDynamicFields>--%>
                </li>
            </ItemTemplate>
        </telerik:RadListView>
        <sf:TotalProductsControl runat="server" ID="totalProductsControlBottom" CssClass="sfCatalogTotalCount" />
        <sf:Pager id="pager" runat="server" DisplayCount="3" ShowPrevAndNext="true" CssClass="sfCatalogPager" />
        <sf:ItemsPerPageSelector ID="itemsPerPageSelectorBottom" runat="server" GroupingKey="Products" CssClass="sfitemsPerPageWrp" />
     
        </div>
    </asp:Placeholder>


    Regards,
    Ivan D. Dimitrov
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  18. C
    C avatar
    1 posts
    Registered:
    30 Apr 2014
    30 Apr 2014
    Link to this post
    Is there a way to remove the add to cart functionality for a product?
  19. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    29 Nov 2016
    02 May 2014
    Link to this post
    Hello,

    It is not recommended to remove the add to cart widget from the page. What I could suggest you is to hide it but not remove it. For example, change the code of the widget to looks like:
    <div class="sfAddToCartWidget" style="display:none">
         <sfOrders:AddToCartWidget ID="addToCartWidget" ProductId='<%# Eval("Id") %>' runat="server" />
    </div>

    Regards,
    Svetoslav Manchev
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
19 posts, 0 answered