I have a Nextjs app, that uses the Wordpress REST API to fetch the products. I maintain the cart within React, and I would like to display the WooCommerce checkout page inside an iframe.
I made a custom function in php (I'm not so good with php though), that adds the products to the cart from the url parameters. So the iframe's src looks like this:
https://example.com/<wp_installation_url>/checkout?empty_cart=true&add-to-cart=51,51,53
(51, and 53 being the IDs of the products, and they're repeated by the quantity).
This works perfectly until I'm signed in as the WP site's owner. However when I log out (or open a private page), I get this error on the checkout page:
Sorry, your session has expired. Return to shop
How could I resolve this issue? Maybe fetch an api route in wordpress that would give me a new session? I'm very lost on this one...