Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Garry 12 posts 32 karma points
    May 31, 2010 @ 22:57
    Garry
    0

    Add to basket

    Hello!

    I can't figure out how to add products to basket via XSLT in the demo store.

    What should be inserted into Product[XSLT].xslt to get this functionality?

    There is AddToBasket[XSLT].xslt, but I don't understand what should be done with it.

    Thank you.

  • Søren Spelling Lund 1797 posts 2786 karma points
    Jun 01, 2010 @ 08:42
    Søren Spelling Lund
    0

    Hi Garry,

    Are products showing up in the store when you browse to its URL? You should be able to add products without changing any macros.

  • Björn Jönsson 37 posts 58 karma points
    Jun 01, 2010 @ 08:48
    Björn Jönsson
    0

    Hello Garry!

    There are some minor errors with some of the alias and in the products.xslt file change following:

     Quantity: <input type="text" name="quantityInput" value="1"></input>&nbsp;
    <xsl:if test="$product/product/@hasVariants = 'True'">
    <select name="variantSku">
    <option>Please select</option>
    <xsl:for-each select="$product/product/variants/product">
    <option>
    <xsl:attribute name="value">
    <xsl:value-of select="@variantSku"/>
    </xsl:attribute>
    <xsl:value-of select="@variantSku"/>

    With this change you can select one of the variants that exist and with that you got information that can be passed on to the basket. Hope that will help.

    --Björn Jönsson

  • Björn Jönsson 37 posts 58 karma points
    Jun 01, 2010 @ 08:55
    Björn Jönsson
    0

    Hello Garry!

    I need to clarify: the change I suggested is just for you to see the "variantSku", at least it was so for me. I couldn´t see any variants so I suspected that you couldn´t either, but try out Sorens advice first.

    Kind Regards

    --Björn Jönsson

  • Garry 12 posts 32 karma points
    Jun 01, 2010 @ 12:58
    Garry
    0

    Hi Guys,

    Thanks for the replies, but I rewrote the store completely in c# (asp user controls instead of XSLTs). It seems uCommerce XSLT layer doesn' work well with my configuration (IIS 7.0, etc.). Now the store works fine, but I can't figure out how to add the product in basket from c# code.

  • Søren Spelling Lund 1797 posts 2786 karma points
    Jun 01, 2010 @ 13:26
    Søren Spelling Lund
    0

    The easiest way to add to basket from .NET is to use:

    Library.AddToBasket(string catalogName, int quantity, string sku, string variantSku);

    You need to make sure that the URL you're using is configured for a store, e.g. a hostname is configured in Umbraco and that same hostname is set for on the store level (the top level in uCommerce Admin in Product Catalog) in uCommerce.

    Also you need to have the catalog name as part of the URL (myPage.aspx?catalog=MyCatalog) or you can override the current catalog to your current catalog name manually with the following code:

    SiteContext.CatalogContext.CurrentCatalogName = "MyCatalog";
  • Søren Spelling Lund 1797 posts 2786 karma points
    Jun 01, 2010 @ 13:30
    Søren Spelling Lund
    0

    Just wanted to add a quick note about XSLT library and IIS7.

    Our XSLT extensions work well with IIS7, in fact they are tested with both IIS6 and IIS7 and we haven't seen any issues particular to any of these IIS versions.

    Problems with the XSLT extensions usually arise when the store isn't configured to work with a content node. The process of configuring a store with a URL is demonstrated in Installing and Configuring uCommerce Store.

  • Garry 12 posts 32 karma points
    Jun 01, 2010 @ 16:07
    Garry
    0

    Thank you!

  • Søren Spelling Lund 1797 posts 2786 karma points
    Jun 02, 2010 @ 08:36
    Søren Spelling Lund
    0

    If one of the replies helped you solve the problem could you please mark it as the solution?

    Thanks.

  • Garry 12 posts 32 karma points
    Jun 02, 2010 @ 20:34
    Garry
    0

    Just one more question regarding the baskets.
    I'm using the recommended code to add products to basket.

    Library.AddToBasket(string catalogName, int quantity, string sku, string variantSku);

    But my basket is user independant. It is the same for all users and even when ClientContext.IsLoggedOn is false and ClientContext.CurrentMemberName is null.
    How can I get/create baskets for each user using your library?

    Thank you.

  • Søren Spelling Lund 1797 posts 2786 karma points
    Jun 03, 2010 @ 08:57
    Søren Spelling Lund
    0

    uCommerce uses cookies to identify individual baskets so you need to make sure that cookies are enabled on your machine otherwise you'll get a new basket every time you add something to the basket. This will happen automatically inside the APIs so you shouldn't have to worry about it.

    You can verify if this is the case by looking in the uCommerce_PurchaseOrder table. If you see new orders created in quick succession then you might have to look at whether a firewall or browser is blocking cookies on your site.

    To retrieve the existing basket for a user you can use SiteContext.ClientContext.GetBasket(true) to get the current basket for a user. The true parameter tells uCommerce to create a new basket for that user if no basket exists in cookie or session to start from.

    AddToBasket uses GetBasket internally and will create a new basket for you if you don't have one already.

     

  • Don Ross 28 posts 49 karma points
    Nov 29, 2011 @ 16:26
    Don Ross
    0

    Hi,

    I have tried everything to programmatically add a product to the basket, but cannot seem to get this to work with the latest UCommerce. I have tried both the XSLT.AddToBasket(), as well as the Basket() AddProduct methods. The error I am getting with the XSLT.AddToBasket() is 'The product with sku 'xxxxxxx' does not have a price in the price group "USD"'. I added the price group and can add the product to the cart from the front-end, but not via the API. I have set the context for the CatalogName and tried this in many different ways to no avail. Any assistance would be greatly appreciated!

    Thanks!

    Don

Please Sign in or register to post replies

Write your reply to:

Draft