Author Topic: API call Add to Cart is not reflected in in Browser for the same user  (Read 1788 times)

Offline Milan_VC

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Hi -

Since this is the first time I am writing: First off - great work and thank you for the platform.

Here is my issue / question.

AbanteCart : 1.3

I have a need to use API to add to cart and for this to be reflected for a user in a browser. What I observe at the moment:

- User is logged in on the browser and adds item #1 in the cart
- Via API, I authenticate the same user as above and add item #2 to a cart via a/checkout/cart. This returns result showing both item 1 and item 2 are in the cart.
- In the browser - even after a refresh page or closing and re-opening a browser - user still only sees item #1 in the cart
- in the browser - if user logs off and back on - user will see both item 1 and item 2 in the cart

Questions:
- Is there a way to force the refresh of the cart for user in a browser so that this user can see both items? Logging off and back on is not really an option.

Note: I cannot really use embed/js for a number of reasons including dynamic nature of products and other limitations ... so API add-to-cart as described above is possibly the only solution.

Thanks for the help!

Offline abantecart

  • Administrator
  • Hero Member
  • *****
  • Posts: 4358
  • Karma: +298/-10
    • View Profile
    • Ideal Open Source Ecommerce Solution
Hello Milan_VC,

Welcome to AbanteCart forum.

What you describe is a correct behavior. Customer's active cart is stored in the session and specific to given session. Once the session is lost or customer is logged off, sessions is cleared.
With new login, last cart content will be loaded from the database.
To achieve you requirement, you will need to reload cart from database all the time.
This code is in the customer class
https://github.com/abantecart/abantecart-src/blob/master/public_html/core/lib/customer.php#L191
Please  rate your experience or leave your review
We need your help to build better free open source ecommerce platform for everyone. See how you can help

 

Powered by SMFPacks Social Login Mod