The auto-magic nature of going from the catalog to an order keeps most store owners from thinking too hard about sessions, carts, checkout forms, etc.
…until they decide to create a unique checkout experience for their customers—then advanced WooCommerce developers need to get into the code to fine-tune the experience.
Let’s take a look behind the curtain…
If you prefer to bypass the lesson, and jump straight to the quiz: click here
The WooCommerce Session remembers the customers’ selections, information and data by linking a database entry to a cookie in the user’s browser
The cart, which is stored in the session, stores selections for a future order and calculates the order’s pricing.
The WC_Checkout singleton object collects additional information and builds an order.
WooCommerce’s core provides an abstract WC_Session class, which can be used to create a custom handler, and a default session handler, which can be overriddenThis allows you to consider unique implementations of the session handler–e.g. Perhaps instead of using a cookie on the customer’s browser it would be better to use the fingerprint or IP address
Two additional classes directly pertain to specific data sets with in the WC session:
A sessionIn it’s default implementation “connects” with the user’s browser using the wp_woocommerce_session cookie
Two additional cookies are set, which are primarily used by the front-end’s refresh_cart_fragmentsWhich is much maligned, for performance reasons. functionality:
WC_Sessions are stored in the woocommerce_sessions table in the database. The fields are fairly straightforward:
|session_id||Unique ID int|
|session_value||Serialized array of all the data associated with the customer’s session|
|session_exipry||timestamp of session’s expiration|
Conceptually simple, but practically complex, the WC_Cart classes in WooCommerce do a lot of heavy lifting. We’ll dive into the details later.
We’ll take an even deeper dive into each of these components in subsequent topics, then take a look at a couple uses cases for creating a unique browsing and checkout experience for your customers.
Let’s do a quick knowledge check, before moving on to the next topics
0 of 4 Questions completed
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
0 of 4 Questions answered correctly
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Which of the following is responsible for remembering the customer’s selections and information:
Which of the following is responsible for managing the cost calculations of a customer’s products
Which of the following is responsible for building a customer’s order?
How does WooCommerce store information about customers?