WooCommerce Code Reference

Search results

WC_Legacy_Cart

Legacy cart class.

Table of Contents

$cart_session_data Array of defaults. Not used since 3.2.
$coupon_applied_count Contains an array of coupon usage counts after they have been applied. array
__isset() Map legacy variables. mixed
__get() Magic getters. mixed
__set() Map legacy variables to setters. mixed
get_cart_from_session() Methods moved to session class in 3.2.0. mixed
maybe_set_cart_cookies() mixed
set_session() mixed
get_cart_for_session() mixed
persistent_cart_update() mixed
persistent_cart_destroy() mixed
get_cart_discount_total() Get the total of all cart discounts. float
get_cart_discount_tax_total() Get the total of all cart tax discounts (used for discounts on tax inclusive prices). float
add_discount() Renamed for consistency. bool
remove_taxes() Remove taxes. mixed
init() Init. mixed
get_discounted_price() Function to apply discounts to a product and get the discounted price (before tax is applied). float
get_cart_url() Gets the url to the cart page. string
get_checkout_url() Gets the url to the checkout page. string
ship_to_billing_address_only() Sees if we need a shipping address. bool
coupons_enabled() Coupons enabled function. Filterable. bool
get_discounts_before_tax() Gets the total (product) discount amount - these are applied before tax. mixed
get_order_discount_total() Get the total of all order discounts (after tax discounts). int
apply_cart_discounts_after_tax() Function to apply cart discounts after tax. mixed
apply_product_discounts_after_tax() Function to apply product discounts after tax. mixed
get_discounts_after_tax() Gets the order discount amount - these are applied after tax. mixed

Properties

$cart_session_data

Array of defaults. Not used since 3.2.

public mixed $cart_session_data = array('cart_contents_total' => 0, 'total' => 0, 'subtotal' => 0, 'subtotal_ex_tax' => 0, 'tax_total' => 0, 'taxes' => array(), 'shipping_taxes' => array(), 'discount_cart' => 0, 'discount_cart_tax' => 0, 'shipping_total' => 0, 'shipping_tax_total' => 0, 'coupon_discount_amounts' => array(), 'coupon_discount_tax_amounts' => array(), 'fee_total' => 0, 'fees' => array())

$coupon_applied_count

Contains an array of coupon usage counts after they have been applied.

public array $coupon_applied_count = array()

Methods

__isset()

Map legacy variables.

public __isset( $name : string ) : mixed
Parameters
$name : string

Property name.

Return values
mixed

__get()

Magic getters.

public __get( $name : string ) : mixed

If you add/remove cases here please update $legacy_keys in __isset accordingly.

Parameters
$name : string

Property name.

Return values
mixed

__set()

Map legacy variables to setters.

public __set( $name : string , $value : mixed ) : mixed
Parameters
$name : string

Property name.

$value : mixed

Value to set.

Return values
mixed

get_cart_from_session()

Methods moved to session class in 3.2.0.

public get_cart_from_session( ) : mixed
Return values
mixed

persistent_cart_destroy()

public persistent_cart_destroy( ) : mixed
Return values
mixed

get_cart_discount_total()

Get the total of all cart discounts.

public get_cart_discount_total( ) : float
Return values
float

get_cart_discount_tax_total()

Get the total of all cart tax discounts (used for discounts on tax inclusive prices).

public get_cart_discount_tax_total( ) : float
Return values
float

add_discount()

Renamed for consistency.

public add_discount( $coupon_code : string ) : bool
Parameters
$coupon_code : string
Return values
bool

True if the coupon is applied, false if it does not exist or cannot be applied.

remove_taxes()

Remove taxes.

public remove_taxes( ) : mixed
Tags
deprecated

Taxes are never calculated if customer is tax except making this function unused.

Return values
mixed

init()

Init.

public init( ) : mixed
Tags
deprecated

Session is loaded via hooks rather than directly.

Return values
mixed

get_discounted_price()

Function to apply discounts to a product and get the discounted price (before tax is applied).

public get_discounted_price( $values : mixed , $price : mixed [, $add_totals : bool = false ] ) : float
Parameters
$values : mixed

Cart item.

$price : mixed

Price of item.

$add_totals : bool = false

Legacy.

Tags
deprecated

Calculation and coupon logic is handled in WC_Cart_Totals.

Return values
float

price

get_cart_url()

Gets the url to the cart page.

public get_cart_url( ) : string
Tags
deprecated

in favor to wc_get_cart_url()

Return values
string

url to page

get_checkout_url()

Gets the url to the checkout page.

public get_checkout_url( ) : string
Tags
deprecated

in favor to wc_get_checkout_url()

Return values
string

url to page

ship_to_billing_address_only()

Sees if we need a shipping address.

public ship_to_billing_address_only( ) : bool
Tags
deprecated

in favor to wc_ship_to_billing_address_only()

Return values
bool

coupons_enabled()

Coupons enabled function. Filterable.

public coupons_enabled( ) : bool
Tags
deprecated
Return values
bool

get_discounts_before_tax()

Gets the total (product) discount amount - these are applied before tax.

public get_discounts_before_tax( ) : mixed
Tags
deprecated

Order discounts (after tax) removed in 2.3 so multiple methods for discounts are no longer required.

Return values
mixed

formatted price or false if there are none.

get_order_discount_total()

Get the total of all order discounts (after tax discounts).

public get_order_discount_total( ) : int
Tags
deprecated

Order discounts (after tax) removed in 2.3.

Return values
int

apply_cart_discounts_after_tax()

Function to apply cart discounts after tax.

public apply_cart_discounts_after_tax( $values : , $price : ) : mixed
Parameters
$values :
$price :
Tags
deprecated

Coupons can not be applied after tax.

Return values
mixed

apply_product_discounts_after_tax()

Function to apply product discounts after tax.

public apply_product_discounts_after_tax( $values : , $price : ) : mixed
Parameters
$values :
$price :
Tags
deprecated

Coupons can not be applied after tax.

Return values
mixed

get_discounts_after_tax()

Gets the order discount amount - these are applied after tax.

public get_discounts_after_tax( ) : mixed
Tags
deprecated

Coupons can not be applied after tax.

Return values
mixed
Back to the top