WC_Cart_Fees
in package
WC_Cart_Fees class.
Tags
Table of Contents
- $default_fee_props : array<string|int, mixed>
- New fees are made out of these props.
- $fees : array<string|int, object>
- An array of fee objects.
- __construct() : mixed
- Constructor. Reference to the cart.
- add_fee() : object
- Add a fee. Fee IDs must be unique.
- get_fees() : array<string|int, mixed>
- Get fees.
- init() : mixed
- Register methods for this object on the appropriate WordPress hooks.
- remove_all_fees() : mixed
- Remove all fees.
- set_fees() : mixed
- Set fees.
- sort_fees_callback() : int
- Sort fees by amount.
- generate_id() : string
- Generate a unique ID for the fee being added.
Properties
$default_fee_props
New fees are made out of these props.
private
array<string|int, mixed>
$default_fee_props
= array('id' => '', 'name' => '', 'tax_class' => '', 'taxable' => alse, 'amount' => 0, 'total' => 0)
$fees
An array of fee objects.
private
array<string|int, object>
$fees
= array()
Methods
__construct()
Constructor. Reference to the cart.
public
__construct([null $deprecated = null ]) : mixed
Parameters
- $deprecated : null = null
-
Deprecated since WooCommerce 8.2.0.
Tags
Return values
mixed —add_fee()
Add a fee. Fee IDs must be unique.
public
add_fee([array<string|int, mixed> $args = array() ]) : object
Parameters
- $args : array<string|int, mixed> = array()
-
Array of fee properties.
Tags
Return values
object — Either a fee object if added, or a WP_Error if it failed.get_fees()
Get fees.
public
get_fees() : array<string|int, mixed>
Return values
array<string|int, mixed> —init()
Register methods for this object on the appropriate WordPress hooks.
public
init() : mixed
Return values
mixed —remove_all_fees()
Remove all fees.
public
remove_all_fees() : mixed
Tags
Return values
mixed —set_fees()
Set fees.
public
set_fees([array<string|int, object> $raw_fees = array() ]) : mixed
Parameters
- $raw_fees : array<string|int, object> = array()
-
Array of fees.
Return values
mixed —sort_fees_callback()
Sort fees by amount.
protected
sort_fees_callback(stdClass $a, stdClass $b) : int
Parameters
- $a : stdClass
-
Fee object.
- $b : stdClass
-
Fee object.
Return values
int —generate_id()
Generate a unique ID for the fee being added.
private
generate_id(string $fee) : string
Parameters
- $fee : string
-
Fee object.