You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been following this guide because i want to make a Shopify like checkout, which means that i use a mutation to create a cart and then use this url to redirect to the checkout which has the predefined items already in it.
The problem that i am facing is that in the above mentioned tutorial i need to write php code on the server which i either package into a plugin or put it in the functions.php.
The guide accomplishes this by letting the frontend make an addToCart mutation and puts the items which have to be available at checkout in it
e.g. making a cart for a checkout with a single product in it mutation { addToCart(input: {productId: 13}) { cart { total } } }
then save the "woocommerce-session" token out of the response header, decode it (because its a JWT) and then get the session which has the items stored in the cart (due to the cart mutation.
The decoded session is then passed as an url argument e.g. (woocommerce-page.com/checkout/session_id=${sessionId})
Now the woocommerce backend takes this url argument and reconstructs the session (code found in guide).
It seems like this is possible without writing custom php code for the backend since we can create checkoutUrls and transfer the session via transfer-session endpoint.
But how do I put the item which i want to have in the checkout in the cart and not loose the checkoutUrl in the process without going through above mentioned trouble?
The text was updated successfully, but these errors were encountered:
I've been following this guide because i want to make a Shopify like checkout, which means that i use a mutation to create a cart and then use this url to redirect to the checkout which has the predefined items already in it.
The problem that i am facing is that in the above mentioned tutorial i need to write php code on the server which i either package into a plugin or put it in the functions.php.
The guide accomplishes this by letting the frontend make an addToCart mutation and puts the items which have to be available at checkout in it
e.g. making a cart for a checkout with a single product in it
mutation { addToCart(input: {productId: 13}) { cart { total } } }
then save the "woocommerce-session" token out of the response header, decode it (because its a JWT) and then get the session which has the items stored in the cart (due to the cart mutation.
The decoded session is then passed as an url argument e.g. (woocommerce-page.com/checkout/session_id=${sessionId})
Now the woocommerce backend takes this url argument and reconstructs the session (code found in guide).
It seems like this is possible without writing custom php code for the backend since we can create checkoutUrls and transfer the session via transfer-session endpoint.
But how do I put the item which i want to have in the checkout in the cart and not loose the checkoutUrl in the process without going through above mentioned trouble?
The text was updated successfully, but these errors were encountered: