Copied to clipboard

Flag this post as spam?

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


  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Aug 20, 2013 @ 16:26
    Matt Brailsford
    0

    AddOrUpdateOrderLine incrementing qty instead of adding new orderline

    Hi Guys,

    I've implemented adding a product to the basket using FormPost.aspx and ajax form as follows:

    <form action="/base/TC/FormPost.aspx" method="post" class="ajaxForm">
        <input name="storeId" type="hidden" value="@storeId" />
        <input name="AddOrUpdateOrderLine" type="hidden" value="productIdentifier : productIdentifier, quantity : quantity" />
        <input name="productIdentifier" type="hidden" value="@Model.Content.Id" />
        <input type="text" name="quantity" />
        <button type="submit" class="addToCart">Add to cart</button>
    </form>
    

    When I hit submit on product 1, it's successfully added to the basket. However on product 2 (a different page) when I hit add to cart, it just increases the quantity on product 1 in the cart, rather than adding product 2.

    I've checked the data being sent to the FormPost.aspx and productIdentifier is definitely different each time, but for some reason it just doesn't doesn't want to add product 2.

    Any suggestions?

    Many thanks

    Matt

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Aug 20, 2013 @ 17:04
    Matt Brailsford
    1

    Ahhh, my bad, I had forgotten to give the 2 products a unique sku, so when it was looking the product up in the cart, because neither had an sku, it was falsley matching them.

    Adding sku's fixed it :)

    Matt

  • Rune Grønkjær 1371 posts 3102 karma points
    Aug 21, 2013 @ 08:03
    Rune Grønkjær
    0

    Good thing you figured it out :)

    Give yourself a correct answer so others can see you solved it.

    /Rune

  • Anders Burla 2560 posts 8256 karma points
    Aug 21, 2013 @ 09:10
    Anders Burla
    0

    One thing is that Matt will give it a shot today and remove the sku and see if there is a bug in Tea Commerce. Try and remove the sku's and see what sku Tea Commerce gives the first order line. It should fallback to use the nodeId as sku.

    Kind regards
    Anders

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Aug 21, 2013 @ 10:04
    Matt Brailsford
    0

    Hey Guys,

    So here is what is happening. My site structure is as follows:

    Store
    --- Category [DocType: Category]
    ------ Product 1 [DocType: Product]
    --------- Variant 1 [DocType: Product]
    --------- Variant 2 [DocType: Product]

    So Product 1 has an sku, but Vairants 1 and 2 didn't. Now when either Vairant 1 or Variant 2 were added to the cart, they ended up with the sku of Product 1, therfore in the cart the quantity was incremented rather than a new order line created.

    Hope this helps

    Cheers

    Matt

  • Anders Burla 2560 posts 8256 karma points
    Aug 21, 2013 @ 10:08
    Anders Burla
    0

    That is an expected and correct behavier. You will learn more about that at the UK Tea Commerce certification cource :)
    Every product should have a unique SKU if you use SKU. Else dont have any at all and use the node id as SKU.

    Kind regards
    Anders

Please Sign in or register to post replies

Write your reply to:

Draft