WC_Cart_Session
in package
WC_Cart_Session class.
Tags
Table of Contents
- $cart : WC_Cart
- Reference to cart object.
- __construct() : mixed
- Sets up the items provided, and calculate totals.
- destroy_cart_session() : mixed
- Destroy cart session data.
- get_cart_for_session() : array<string|int, mixed>
- Returns the contents of the cart in an array without the 'data' element.
- get_cart_from_session() : mixed
- Get the cart data from the PHP session and store it in class variables.
- init() : mixed
- Register methods for this object on the appropriate WordPress hooks.
- maybe_set_cart_cookies() : mixed
- Will set cart cookies if needed and when possible.
- persistent_cart_destroy() : mixed
- Delete the persistent cart permanently.
- persistent_cart_update() : mixed
- Save the persistent cart when the cart is updated.
- set_cart() : mixed
- Sets the cart instance.
- set_session() : mixed
- Sets the php session data for the cart and coupons.
- dedupe_cookies() : mixed
- Remove duplicate cookies from the response.
- find_cookie_by_name() : mixed
- Find a cookie by name in an array of cookies.
- get_saved_cart() : array<string|int, mixed>
- Get the persistent cart from the database.
- populate_cart_from_order() : array<string|int, mixed>
- Get a cart from an order, if user has permission.
- set_cart_cookies() : mixed
- Set cart hash cookie and items in cart if not already set.
Properties
$cart
Reference to cart object.
protected
WC_Cart
$cart
Tags
Methods
__construct()
Sets up the items provided, and calculate totals.
public
__construct(WC_Cart $cart) : mixed
Parameters
- $cart : WC_Cart
-
Cart object to calculate totals for.
Tags
Return values
mixed —destroy_cart_session()
Destroy cart session data.
public
destroy_cart_session() : mixed
Tags
Return values
mixed —get_cart_for_session()
Returns the contents of the cart in an array without the 'data' element.
public
get_cart_for_session() : array<string|int, mixed>
Return values
array<string|int, mixed> — contents of the cartget_cart_from_session()
Get the cart data from the PHP session and store it in class variables.
public
get_cart_from_session() : mixed
Tags
Return values
mixed —init()
Register methods for this object on the appropriate WordPress hooks.
public
init() : mixed
Return values
mixed —maybe_set_cart_cookies()
Will set cart cookies if needed and when possible.
public
maybe_set_cart_cookies() : mixed
Headers are only updated if headers have not yet been sent.
Tags
Return values
mixed —persistent_cart_destroy()
Delete the persistent cart permanently.
public
persistent_cart_destroy() : mixed
Return values
mixed —persistent_cart_update()
Save the persistent cart when the cart is updated.
public
persistent_cart_update() : mixed
Return values
mixed —set_cart()
Sets the cart instance.
public
set_cart(WC_Cart $cart) : mixed
Parameters
- $cart : WC_Cart
-
Cart object.
Return values
mixed —set_session()
Sets the php session data for the cart and coupons.
public
set_session() : mixed
Return values
mixed —dedupe_cookies()
Remove duplicate cookies from the response.
private
dedupe_cookies() : mixed
Return values
mixed —find_cookie_by_name()
Find a cookie by name in an array of cookies.
private
find_cookie_by_name(string $cookie_name, array<string|int, mixed> $cookies) : mixed
Parameters
- $cookie_name : string
-
Name of the cookie to find.
- $cookies : array<string|int, mixed>
-
Array of cookies to search.
Return values
mixed — Key of the cookie if found, false if not.get_saved_cart()
Get the persistent cart from the database.
private
get_saved_cart() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —populate_cart_from_order()
Get a cart from an order, if user has permission.
private
populate_cart_from_order(int $order_id, array<string|int, mixed> $cart) : array<string|int, mixed>
Parameters
- $order_id : int
-
Order ID to try to load.
- $cart : array<string|int, mixed>
-
Current cart array.
Tags
Return values
array<string|int, mixed> —set_cart_cookies()
Set cart hash cookie and items in cart if not already set.
private
set_cart_cookies([bool $set = true ]) : mixed
Parameters
- $set : bool = true
-
Should cookies be set (true) or unset.