skip to Main Content

I’m new to WordPress & Woocommerce and have been trying to get cart content using cocart’s for a website running on a different domain to sync the cart between a Woocommerce website and a React Application

I’ve added some products in the cart from the shop website and calling the "mydomain.com/wp-json/cocart/v1/get-cart" REST API from Postman but getting an empty array in the response.

From their doc, they mentioned a Cart Key and Cookie: wp_cocart_session_, but I’m confused on how to get the Cart Key.

Any kind of help will be highly appreciated.

Thanks in advance

2

Answers


  1. use this plugin

    https://wordpress.org/plugins/cart-rest-api-for-woocommerce/

    or you can save the product id in sqlite and fetch data from woocommerce rest api to every product in the sqlite database and count the total

    Login or Signup to reply.
  2. I had the same problem. Cookies apparently need to be sent with the request as well as the cart_key.

    I solved this by installing the Postman Interceptor browser extension.

    In Postman, click "Cookies" and it should ask if you want to setup Interceptor for the domain that you are requesting from. It will install a browser extension and get the cookies and add them to your Postman requests.

    Postman provides an assisted step-by-step setup of Interceptor and cookie capture, but to manually access cookie capture settings click the icon in the upper right of Postman that says "Capture requests and cookies with Postman". That’s where those setting are.

    More about Interceptor here: https://learning.postman.com/docs/sending-requests/capturing-request-data/interceptor/#installing-interceptor

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search