WooCommerce Code Reference

WC_Shipping_Rate

Shipping rate class.

Table of Contents

$data  : array<string|int, mixed>
Stores data for this rate.
$meta_data  : array<string|int, mixed>
Stores meta data for this rate.
__construct()  : mixed
Constructor.
__get()  : mixed
Magic methods to support direct access to props.
__isset()  : bool
Magic methods to support direct access to props.
__set()  : mixed
Magic methods to support direct access to props.
add_meta_data()  : mixed
Add some meta data for this rate.
get_cost()  : string
Get rate cost.
get_id()  : string
Get ID for the rate. This is usually a combination of the method and instance IDs.
get_instance_id()  : int
Get instance ID the rate belongs to.
get_label()  : string
Get rate label.
get_meta_data()  : array<string|int, mixed>
Get all meta data for this rate.
get_method_id()  : string
Get shipping method ID the rate belongs to.
get_shipping_tax()  : float
Get shipping tax.
get_taxes()  : array<string|int, mixed>
Get rate taxes.
set_cost()  : mixed
Set rate cost.
set_id()  : mixed
Set ID for the rate. This is usually a combination of the method and instance IDs.
set_instance_id()  : mixed
Set instance ID the rate belongs to.
set_label()  : mixed
Set rate label.
set_method_id()  : mixed
Set shipping method ID the rate belongs to.
set_taxes()  : mixed
Set rate taxes.

Properties

$data

Stores data for this rate.

protected array<string|int, mixed> $data = array('id' => '', 'method_id' => '', 'instance_id' => 0, 'label' => '', 'cost' => 0, 'taxes' => array())
Tags
since
3.2.0

Methods

__construct()

Constructor.

public __construct([string $id = '' ][, string $label = '' ], int $cost[, array<string|int, mixed> $taxes = array() ][, string $method_id = '' ], int $instance_id) : mixed
Parameters
$id : string = ''

Shipping rate ID.

$label : string = ''

Shipping rate label.

$cost : int

Cost.

$taxes : array<string|int, mixed> = array()

Taxes applied to shipping rate.

$method_id : string = ''

Shipping method ID.

$instance_id : int

Shipping instance ID.

Return values
mixed

__get()

Magic methods to support direct access to props.

public __get(string $key) : mixed
Parameters
$key : string

Key.

Tags
since
3.2.0
Return values
mixed

__isset()

Magic methods to support direct access to props.

public __isset(string $key) : bool
Parameters
$key : string

Key.

Tags
since
3.2.0
Return values
bool

__set()

Magic methods to support direct access to props.

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

Key.

$value : mixed

Value.

Tags
since
3.2.0
Return values
mixed

add_meta_data()

Add some meta data for this rate.

public add_meta_data(string $key, string $value) : mixed
Parameters
$key : string

Key.

$value : string

Value.

Tags
since
2.6.0
Return values
mixed

get_id()

Get ID for the rate. This is usually a combination of the method and instance IDs.

public get_id() : string
Tags
since
3.2.0
Return values
string

get_meta_data()

Get all meta data for this rate.

public get_meta_data() : array<string|int, mixed>
Tags
since
2.6.0
Return values
array<string|int, mixed>

get_method_id()

Get shipping method ID the rate belongs to.

public get_method_id() : string
Tags
since
3.2.0
Return values
string

get_taxes()

Get rate taxes.

public get_taxes() : array<string|int, mixed>
Tags
since
3.2.0
Return values
array<string|int, mixed>

set_cost()

Set rate cost.

public set_cost(string $cost) : mixed
Parameters
$cost : string

Shipping rate cost.

Tags
todo

4.0 Prevent negative value being set. #19293

since
3.2.0
Return values
mixed

set_id()

Set ID for the rate. This is usually a combination of the method and instance IDs.

public set_id(string $id) : mixed
Parameters
$id : string

Shipping rate ID.

Tags
since
3.2.0
Return values
mixed

set_instance_id()

Set instance ID the rate belongs to.

public set_instance_id(int $instance_id) : mixed
Parameters
$instance_id : int

Instance ID.

Tags
since
3.2.0
Return values
mixed

set_label()

Set rate label.

public set_label(string $label) : mixed
Parameters
$label : string

Shipping rate label.

Tags
since
3.2.0
Return values
mixed

set_method_id()

Set shipping method ID the rate belongs to.

public set_method_id(string $method_id) : mixed
Parameters
$method_id : string

Shipping method ID.

Tags
since
3.2.0
Return values
mixed

set_taxes()

Set rate taxes.

public set_taxes(array<string|int, mixed> $taxes) : mixed
Parameters
$taxes : array<string|int, mixed>

List of taxes applied to shipping rate.

Tags
since
3.2.0
Return values
mixed