Copied to clipboard

Flag this post as spam?

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


  • Gordon Saxby 1461 posts 1883 karma points
    Oct 01, 2018 @ 08:39
    Gordon Saxby
    0

    Do not combine the same product in basket

    I have a requirement to limit the purchase of certain items to 1. I have stopped the quantity being changed while adding to the basket, but if the same product is added again, it is combined with the previous product and the quantity changes to 2.

    I either need to stop the second (exact same) item being added to the basket, or allow it to be added but as a separate order line.

    Adding it as a separate line in the basket would, I think, be preferable - but is it possible?

  • Rune Grønkjær 1372 posts 3103 karma points
    Oct 02, 2018 @ 08:12
    Rune Grønkjær
    0

    Hi Gordon,

    Depending on how important it is to enforce the 1 item policy you should either:

    Do it on the server Add a custom property to the order line, so you can identify it and then clean up the order everytime it updates. https://docs.teacommerce.net/v3.0.0/reference#notificationcenter

    Use overwriteQuantity This forces the server to overwrite the quantity each time you add to the basket. It's not as secure because anyone can use the TC javascript api to do something else. https://docs.teacommerce.net/v3.0.0/reference#addorupdateorderline

    /Rune

  • Gordon Saxby 1461 posts 1883 karma points
    Oct 03, 2018 @ 14:53
    Gordon Saxby
    0

    OK, I've used NotificationCenter.Order.OrderLinesUpdating to check for the specific product type and set / force the qty to 1. Seems to work!

  • Rune Grønkjær 1372 posts 3103 karma points
    Oct 04, 2018 @ 05:57
    Rune Grønkjær
    0

    That's what I usually do. It's the most secure way to go. Customers can't cheat it that way.

    /Rune

Please Sign in or register to post replies

Write your reply to:

Draft