Crinsane / LaravelShoppingcart

A simple shopping cart implementation for Laravel
MIT License
3.67k stars 1.73k forks source link

API support #669

Open rpmcmurphy opened 2 years ago

rpmcmurphy commented 2 years ago

Does the package work through API endpoints? I tried with Postman and Sanctum. Seems like Add to cart works and returns rowId properly but once contents of the cart is requested, nothing is returned. isSaved param is false when items are added.

    `"8aba6628cc50563aa69002b76af27473": {
        "rowId": "8aba6628cc50563aa69002b76af27473",
        "id": "123ABC",
        "name": "Hello product",
        "qty": 2,
        "price": 9.99,
        "options": [],
        "tax": "0.00",
        "isSaved": false,
        "subtotal": "19.98"
    }`
bumbummen99 commented 2 years ago

No this package does store the cart content in session while the cart is loaded and api has no session. There is a refactor branch where i am currently trying to rewrite it to always store cart content in database & to use pagination - that would make it compatible with API scenario.

Edit: Sorry tought this is a issue in my fork, anyways talkin about this PR's https://github.com/bumbummen99/LaravelShoppingcart/pull/145 https://github.com/bumbummen99/LaravelShoppingcart/pull/148

rpmcmurphy commented 2 years ago

I was implementing an API with the package and found this out. Is the PR (https://github.com/bumbummen99/LaravelShoppingcart) you did production-ready? Need this badly at this point of the project. Wasn't aware of the session part before I started developing the app version of the project.