Adding A Product To Shopping Cart

Daniel Francis asked on January 14, 2016 21:21

I am a Kentico newbie and have a simple question to ask. I've created a Product Detail transformation to display given products that I've added. I would like to simply know how to go about adding the link (or button) to add the product to the shopping cart. I see there is a GetAddToShoppingCartLink method, but it displays as such "EcommerceTransformationFuncitons.AddToShoppingCart" which is the class reference. Question 1, Is this right way to get "Add Product To Cart" link? Secondly, How do I go about specifying a quantity for the product? As I mentioned, I am a newbie to Kentico, so thanks to all that reply?

Correct Answer

Dawid Jachnik answered on January 15, 2016 08:04

Hello Daniel,

You should register it in transformation:

<%@ Register Src="~/CMSModules/Ecommerce/Controls/ProductOptions/ShoppingCartItemSelector.ascx" TagName="CartItemSelector" TagPrefix="uc1" %>

then you can use it, where you want to display these links

<uc1:CartItemSelector id="addItem" runat="server" SKUID='<%# EvalInteger("SKUID") %>' SKUEnabled='<%# EvalBool("SKUEnabled") %>' AddToCartTooltip="Add to cart" AddToCartText="Add to cart" ShowWishlistLink="false" ShowUnitsTextBox="true" AlwaysShowTotalPrice="true" TotalPriceLabel="Total" ShowProductOptions="true" StockVisible="true" UnavailableVariantInfoEnabled="false" UsedInProductDetail="true" CssClassNormal="normal" CssClassFade="fade" QuantityText="Qty"  />
0 votesVote for this answer Unmark Correct answer

Recent Answers


Joshua Adams answered on January 14, 2016 22:32

I would suggest using the shopping cart item selector control and registering it in an ascx transformation. The best thing for you would be to look at a default Kentico installation and install the ecommerce site. Then look at how they use the control in their transformation. That should have everything you need.

0 votesVote for this answer Mark as a Correct answer

Daniel Francis answered on January 14, 2016 22:45

Joshua thank you for the response. Does this apply to earlier versions of Kentico? I'm currently on v8.2.18 and I am unable to find the ShoppingCartItemSelector control. Is this a webpart that I should be looking for?

0 votesVote for this answer Mark as a Correct answer

Daniel Francis answered on January 15, 2016 15:39 (last edited on January 15, 2016 15:40)

That worked! Thank you so much. Unfortunately I do not have access to sample sites with my Kentico installation. It looks like our vendors only setup our site (as that's the only available site that I can select). Is there a listing of predefined user controls in Kentico documentation anywhere? I've been going through the documentation to set up things, but run into a few situations like this where certain concepts are not documented and thus require more digging.

0 votesVote for this answer Mark as a Correct answer

Dawid Jachnik answered on January 15, 2016 15:47

Try to use Hosted Trial to get your sample site, there's a lot of best practice stuff.

0 votesVote for this answer Mark as a Correct answer

Daniel Francis answered on January 15, 2016 16:01

Thank you Dawid, I'll start there.

0 votesVote for this answer Mark as a Correct answer

jason jorgenson answered on April 18, 2016 16:31

How would you change the default number of items that is in the text field instead of 1?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.