WooCommerce Code Reference

Search results

WC_Shipping_Rate

Shipping rate class.

Table of Contents

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

Properties

$data

Stores data for this rate.

protected array $data = array('id' => '', 'method_id' => '', 'instance_id' => 0, 'label' => '', 'cost' => 0, 'taxes' => array())

Methods

__construct()

Constructor.

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

Shipping rate ID.

$label : string = ''

Shipping rate label.

$cost : int

Cost.

$taxes : array = array()

Taxes applied to shipping rate.

$method_id : string = ''

Shipping method ID.

$instance_id : int

Shipping instance ID.

Return values
mixed

__isset()

Magic methods to support direct access to props.

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

Key.

Tags
since
Return values
bool

__get()

Magic methods to support direct access to props.

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

Key.

Tags
since
Return values
mixed

__set()

Magic methods to support direct access to props.

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

Key.

$value : mixed

Value.

Tags
since
Return values
mixed

set_id()

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

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

Shipping rate ID.

Tags
since
Return values
mixed

set_method_id()

Set shipping method ID the rate belongs to.

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

Shipping method ID.

Tags
since
Return values
mixed

set_instance_id()

Set instance ID the rate belongs to.

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

Instance ID.

Tags
since
Return values
mixed

set_label()

Set rate label.

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

Shipping rate label.

Tags
since
Return values
mixed

set_cost()

Set rate cost.

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

Shipping rate cost.

Tags
todo

4.0 Prevent negative value being set. #19293

since
Return values
mixed

set_taxes()

Set rate taxes.

public set_taxes( $taxes : array ) : mixed
Parameters
$taxes : array

List of taxes applied to shipping rate.

Tags
since
Return values
mixed

get_id()

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

public get_id( ) : string
Tags
since
Return values
string

get_method_id()

Set shipping method ID the rate belongs to.

public get_method_id( ) : string
Tags
since
Return values
string

get_instance_id()

Set instance ID the rate belongs to.

public get_instance_id( ) : int
Tags
since
Return values
int

add_meta_data()

Add some meta data for this rate.

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

Key.

$value : string

Value.

Tags
since
Return values
mixed

get_meta_data()

Get all meta data for this rate.

public get_meta_data( ) : array
Tags
since
Return values
array
Back to the top