I am building a 3-step checkout. The first step is an email field, which prompts you to log in if you are registered, but otherwise should just save the email so on subsequent pages it doesn't need to be entered again. The second step is a product selection - like "Variation A or B" and the third is a payment form. When I finally call wc_create_customer() (on payment submission by a non-logged-in user) I want to grab that email (and maybe other things, like step 2) reliably from WC_Customer. Can I set the session cookie and start using WC_Customer without items in the cart? Or is it unreliable/a bad idea? Using the various WC_Session-related functions seem either to not write, or not retain, or not be able to recall what I've written.
So:
-
When can I initialize the session (
set_customer_session_cookie())? Does this conflict with anything? -
How should I write to the session and when, and when can I recall what I've written?
-
Is this unreliable or hazardous for any reason?
I should note, for those who would ask why, this checkout is for a non-WC product but must still use my WC customers database. So, there isn't anything to put in the cart to trigger the normal session behaviour.
from How can I use WC_Session / WC_Customer with nothing in the cart?
No comments:
Post a Comment