• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Register
  • Login
Bagisto Forum

Bagisto

  • Register
  • Login
  • Search
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups

Not able to get Cart items

Modules
customers bagisto api
2
8
1.3k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A
    Akanrat last edited by 25 May 2021, 14:29

    Hi i am trying to get the cart data but i m not able to get it
    /api/checkout/cart Api that i used response code is 200
    {"data":null} response is null

    1 Reply Last reply Reply Quote 0
    • devansh-webkul
      devansh-webkul last edited by 26 May 2021, 04:34

      Hi @Akanrat,

      In Bagisto, Cart handled via session and the Laravel session is checked on the basis of cookies.

      Laravel is not able to see your cookies that's why every request is getting a new cart.

      1 Reply Last reply Reply Quote 0
      • A
        Akanrat last edited by 26 May 2021, 06:37

        @devansh-webkul how we can make cart on the basis of user such as token or customer id

        1 Reply Last reply Reply Quote 0
        • devansh-webkul
          devansh-webkul last edited by 26 May 2021, 08:05

          Authenticated user cart always linked to customer_id. You can easily grab that.

          1 Reply Last reply Reply Quote 1
          • A
            Akanrat last edited by 26 May 2021, 08:36

            GET http(s)://example.com/api/checkout/cart this api is used for getiing cart who are logged in but where to send customer_id in this ??
            headers:
            Accept: application/json
            Authorization: Bearer token-string

            1 Reply Last reply Reply Quote 0
            • devansh-webkul
              devansh-webkul last edited by 26 May 2021, 08:45

              You don't need to send any customer id, as the cart is session-based once the user is authenticated cart is merged and the user id is set to the current customer id once logged in.

              You just need to grab the cookies once the cart is created and then send the cookies in each reqest.

              If you check the Postman, the postman automatically sends this but once it is in the application you need to store somewhere and send it.

              1 Reply Last reply Reply Quote 0
              • A
                Akanrat last edited by 26 May 2021, 08:50

                If we are getting the data from the help cookies how will i maintain the cart data in different platform for eg i have added 2 shirts in cart from mobile app can i will be able to see these item in web also ???

                1 Reply Last reply Reply Quote 0
                • devansh-webkul
                  devansh-webkul last edited by 26 May 2021, 09:48

                  Hi @Akanrat,

                  If the user is authenticated then yes it will be the same. Because for authenticated user cart is fetched from the database.

                  I think you are getting confused, I am just sharing a thread that will help you,

                  Actually, this is a cross-domain, you need to send the cookies so that session can be tracked. I am sharing with you a thread that can help you just try to send cookies in ajax request and it will work.

                  https://stackoverflow.com/questions/63445307/php-session-id-session-variable-value-changing-on-every-request-from-react-axi

                  https://stackoverflow.com/questions/29417518/how-can-set-cookie-with-ajax-jquery/29417575#29417575

                  https://symfonycasts.com/screencast/reactjs/api-authentication

                  1 Reply Last reply Reply Quote 1
                  1 out of 8
                  • First post
                    1/8
                    Last post