create custom Shopping

hadi tag asked on January 29, 2015 10:55

hi i use kentico 81(Recently) and i have a page with many products(page type) in that. i want insert a 'add to cart' button to products transformation that on click event, add product to shopping cart preview. please help me.

Recent Answers


Brenden Kehren answered on January 29, 2015 14:36

You could use something like this (the key is adding the CartItemSelector control):

<%@ Register Src="~/CMSModules/Ecommerce/Controls/ProductOptions/ShoppingCartItemSelector.ascx"     TagName="CartItemSelector" TagPrefix="uc1" %>
<div class="ProductPreview">
<div class="ProductBox">
    ##editbuttons##
    <div class="ProductTitle">
    <a href="<%# GetDocumentUrl() %>">
        <span class="textContent">
        <%# StripTags(EvalText("SKUShortDescription")) %><br/>
        <%# StripTags(EvalText("SKUNumber")) %>
        </span>
        <span class="indicator <%# GetSKUIndicatorProperty("PublicStatusName") %>">&nbsp;</span> 
        <br class="clear" />
    </a>
    </div>
    <div class="ProductImage">
    <a href="<%# GetDocumentUrl() %>" style="display:block;">
        <img class="part-image" src="<%# IfEmpty(EvalText("SKUImagePath"),  "/MySite/media/no_product_image.png", "/MySite/media/Items/Thumbnails/" + EvalText("SKUImagePath"))%>"  alt="<%# StripTags(EvalText("SKUName")) %>" />
    </a>
    </div>
<div class="ProductFooter">
    <div class="productPrice"><%# GetSKUFormattedPrice() %></div>
    <div class="<%#     (CMS.DataEngine.SettingsKeyInfoProvider.GetBoolValue(CMS.SiteProvider.SiteContext.CurrentSiteName +     ".EnableShoppingCart") ? "" : "invisible")  %>">
    <uc1:CartItemSelector id="cartItemSelector" runat="server" SKUID='<%# EvalInteger("SKUID") %>'  SKUEnabled='<%# EvalBool("SKUEnabled") %>'
AddToCartImageButton="~/images/btn_addToShoppingCart.png" ShowUnitsTextBox="true" AddToCartTooltip="Add     to Cart"/>
    </div>
    </div>
</div>
</div>
1 votesVote for this answer Mark as a Correct answer

hadi tag answered on January 30, 2015 09:06

hi thanks Brenden I change part of your code to :

<uc1:CartItemSelector id="cartItemSelector" runat="server" SKUID='<%# EvalInteger("ShoppingPageTypeID") %>'  SKUEnabled='<%# EvalBool("IsAvailable") %>' ShowUnitsTextBox="true" AddToCartTooltip="Add" AddToCartLinkText="Add" />

but i want that, get product id from my page type While this get from other location

Please help me ...

0 votesVote for this answer Mark as a Correct answer

hadi tag answered on January 30, 2015 09:15

hi

thanks Brenden

I change part of your code to :

<uc1:CartItemSelector id="cartItemSelector" runat="server" SKUID='<%# EvalInteger("ShoppingPageTypeID") %>'  SKUEnabled='<%# EvalBool("IsAvailable") %>' ShowUnitsTextBox="true" AddToCartTooltip="Add" AddToCartLinkText="Add" />

but i want that, get product id from my page type

Image Text

While this get from other location

Please help me ...

0 votesVote for this answer Mark as a Correct answer

hadi tag answered on January 30, 2015 20:41

please help me...

it is very important for me

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on January 30, 2015 23:30

The cart requires the skuID be sent. So if ShoppingPageTypeID is your skuid then it should work just fine, if not, then you need to use the skuid.

0 votesVote for this answer Mark as a Correct answer

hadi tag answered on January 31, 2015 01:55 (last edited on January 31, 2015 01:56)

yes, this sent ShoppingPageTypeID as skuId

but when I send 1 as skuId, alert message is : product 'Apple Ipad 2' is not availabel.

However, I did not have such a product in my products page type.

0 votesVote for this answer Mark as a Correct answer

Josef Dvorak answered on February 19, 2015 11:50

Hello Hadi,

In this case I am not sure what the scenario you are trying to achieve is. The ShoppingCartItemSelector expects SKUID, which comes from a standalone object called SKU. It contains all the required data for the checkout, like Price, Product image, Tax settings, etc. It is not possible to pass just any object ID there. Any value that you pass to the SKUID will be used to get SKU entry from COM_SKU table.

The alert message means that Kentico tried to look-up a SKU entry based on the ID that you specified. IT found the Apple Ipad 2, which is one of our sample products from the Sample Corporate Site template.

Please refer to Products section of our documentation to learn more about how Product information is stored in Kentico.

0 votesVote for this answer Mark as a Correct answer

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