• Resolved Memo

    (@gtenaschuk)


    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!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @gtenaschuk ,

    Thank you for reaching out! While we understand your custom plugin development needs, please note that assistance with custom code is outside of our support scope. However, we highly recommend joining our community Slack channel, where you can collaborate with other developers and get insights or suggestions on your custom development challenges.

    Feel free to check out the community and get in touch with others who might have faced similar issues.

    Best of luck with your project!

    Thread Starter Memo

    (@gtenaschuk)

    @mahfuzurwp

    The problem we have is that when using WC()->session in a REST API endpoint call it is always null and not sure why.

    I will send this question to the slack channel as well to see if someone has the same problem.

    Thanks!

    Zee

    (@doublezed2)

    Hello Memo

    Thank you for your reply.

    I understand you are posting this question on Slack. It is the right channel to seek answers related to custom development. This forum is intended for support related to WooCommerce core features and configurations.

    Have a great day!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Initialize Session in Rest API requests’ is closed to new replies.