Cart
Cart Utilities
Tags
Table of Contents
- check_prerequisities() : bool
- Checks that the cart exists
- get_add_to_cart_validations() : array<string|int, Cart_Validation>
- Gets the cart validations applicable to a specific cart item
- get_cart_item_key() : string|false
- Retrieves the cart item key based on the product and quantity to be added.
- get_cart_validations() : array<string|int, Cart_Validation>
- Retrieves all validations for a given cart.
- get_category_quantity() : mixed
- Gets the total quantity associated to a category
- get_category_total() : mixed
- Gets the total for a category in the cart
- get_global_quantity() : mixed
- Gets the total quantity of items in the cart
- get_global_total() : mixed
- Gets the total in cart
- get_product_quantity() : mixed
- Gets the total quantity of a product in the cart.
- get_product_total() : mixed
- Gets the total for a product in the cart
- get_quantity_in_cart() : int|false
- Retrieves the quantity of a cart item in the cart
- get_variable_product_quantity() : mixed
- Gets the total quantity of variations in the cart associated to a variable product.
- get_variable_product_total() : mixed
- Gets the total for all variations in the cart associated to a variable product.
Methods
check_prerequisities()
Checks that the cart exists
public
static check_prerequisities(WC_Cart $cart) : bool
Parameters
- $cart : WC_Cart
Tags
Return values
bool —get_add_to_cart_validations()
Gets the cart validations applicable to a specific cart item
public
static get_add_to_cart_validations(array<string|int, Cart_Validation> $cart_validations, string $cart_item_key, int $product_id) : array<string|int, Cart_Validation>
Parameters
- $cart_validations : array<string|int, Cart_Validation>
- $cart_item_key : string
- $product_id : int
Tags
Return values
array<string|int, Cart_Validation> —get_cart_item_key()
Retrieves the cart item key based on the product and quantity to be added.
public
static get_cart_item_key(WC_Cart $cart, WC_Product $product, int $quantity) : string|false
Parameters
- $cart : WC_Cart
- $product : WC_Product
- $quantity : int
Tags
Return values
string|false —get_cart_validations()
Retrieves all validations for a given cart.
public
static get_cart_validations(WC_Cart $cart) : array<string|int, Cart_Validation>
Parameters
- $cart : WC_Cart
Tags
Return values
array<string|int, Cart_Validation> —get_category_quantity()
Gets the total quantity associated to a category
public
static get_category_quantity(WC_Cart $cart, int|array<string|int, mixed> $category_ids) : mixed
Parameters
- $cart : WC_Cart
- $category_ids : int|array<string|int, mixed>
-
single category id or array of category ids
Tags
Return values
mixed —get_category_total()
Gets the total for a category in the cart
public
static get_category_total(WC_Cart $cart, int $category_id) : mixed
Parameters
- $cart : WC_Cart
- $category_id : int
Tags
Return values
mixed —get_global_quantity()
Gets the total quantity of items in the cart
public
static get_global_quantity(WC_Cart $cart) : mixed
Parameters
- $cart : WC_Cart
Tags
Return values
mixed —get_global_total()
Gets the total in cart
public
static get_global_total(WC_Cart $cart) : mixed
Parameters
- $cart : WC_Cart
Tags
Return values
mixed —get_product_quantity()
Gets the total quantity of a product in the cart.
public
static get_product_quantity(WC_Cart $cart, string $cart_item_key) : mixed
Parameters
- $cart : WC_Cart
- $cart_item_key : string
Tags
Return values
mixed —get_product_total()
Gets the total for a product in the cart
public
static get_product_total(WC_Cart $cart, string $cart_item_key) : mixed
Parameters
- $cart : WC_Cart
- $cart_item_key : string
Tags
Return values
mixed —get_quantity_in_cart()
Retrieves the quantity of a cart item in the cart
public
static get_quantity_in_cart(WC_Cart $cart, string $cart_item_key) : int|false
Parameters
- $cart : WC_Cart
- $cart_item_key : string
Tags
Return values
int|false —get_variable_product_quantity()
Gets the total quantity of variations in the cart associated to a variable product.
public
static get_variable_product_quantity(WC_Cart $cart, int $variable_id) : mixed
Parameters
- $cart : WC_Cart
- $variable_id : int
Tags
Return values
mixed —get_variable_product_total()
Gets the total for all variations in the cart associated to a variable product.
public
static get_variable_product_total(WC_Cart $cart, int $variable_id) : mixed
Parameters
- $cart : WC_Cart
- $variable_id : int