Initialize Session in Rest API requests
-
Hi Team,
We are working on a custom plugin that will allow you to select tickets from a seat map and purchase them.
The plugin will connect to a external API that will validate if the seat is available and mark the seat as reserved, we are doing this validation and reservation using a Rest API endpoint created in our plugin. As we would like to have the reservation associated with the WooCommerce customer ID we were trying to use the WooCommerce Customer stored in the session but the WC()->session is null on every request and if we try to initialize the session by ourselves, in the woocommerce_init action, and store it in the cookies it is not working properly, it is generating a new random customer ID on every request and trying to store the new id in the cookies.
Also we tried to call the store cookies method on the wp_load action to see if it stored the customer id in the cookies and use it later in the rest-api call but no luck.
Can you please tell us if there is a way to do this? or recommend an option about how we could initialize the session earlier to have the customer id consistent during the session.
Thanks!
The topic ‘Initialize Session in Rest API requests’ is closed to new replies.