Emptying cart when (loggedin user) clicks a button

DennisGeusDennisGeus Posts: 6Member
Hi,
I have two questions.

1.
I need to find a way to empty a cart for a loggedin user when he is not going to order.
This means, he is not going to click the order button. ( I think that is when the cart will show up in the checkout endpoint)

How is the cart saved until that moment?

2.
can a user (logged in with the API) also set to logged out again?



3 comments

  • JaivyDaamJaivyDaam Posts: 22Lightspeed Staff Lightspeed
    Hi @DennisGeus,

    this is a difficult one.
    Especially for logged in users, the shopping carts are always saved under the customer account.
    You'll need to use Javascript or an API listener for every new "Quote", as we handle each cart as a Front-End quote. Whenever a customer hasn't clicked the "Proceed to checkout" button, there won't be a checkout attached to it.

    Also the "Buy Now" button, you'll be able to check the checkout endpoint for it's createdAt timestamp and put logic around that when to send a "DELETE" to our API.

    About the API User, I'm not sure what you mean exactly. When a customer using SSO logging in, you'll have to use your own front-end to log them out. If you talking about API keys, I'm afraid there is not Login/Logout time for that, the API credentials must be sent with every new call or it will fail.

    Maybe you could elaborate on that a little bit more?


  • DennisGeusDennisGeus Posts: 6Member
    maybe it needs a little more explanation.
    I am creating an OCI connection.
    This means I create a login (customerlogin endpoint) for the user on our own server, then the user will be sent to the webshop.
    In the webshop I hide the order buttons etc. with some javascript and create a new one which sends the user (and the cart content) back to our server.
    From there, an OCI post is created to the purchase system of the customer.

    my problem is that when the user wants to order again, the content of the previous order is still in the cart.

    I have retrieved the quotes, but can't find any matching the contents of the cart.

  • DennisGeusDennisGeus Posts: 6Member

    I have done some testing with the quotes endpoint.
    When I get all quotes, I can find one with my IP address.
    id 344039114
    I can retrieve this quote with
    $api->quotes->get(344039114)
    but when I want to get the products
    $api->quotesProducts->get(344039114)
    (so I can delete them) I get an empty array
    [products] => Array
            (
                [resource] => Array
                    (
                        [id] => 
                        [url] => quotes/344039114/products
                        [link] => https://api.webshopapp.com/nl/quotes/344039114/products.json
                    )
    
            )
    So, it seems that there is a product in the Cart but it is not in the quote.







Sign In or Register to comment.