PHP Class WC_Order_Item

A class which represents an item within an order and handles CRUD. Uses ArrayAccess to be BW compatible with WC_Orders::get_items().
Since: 2.7.0
Author: WooThemes
Inheritance: extends WC_Data, implements ArrayAccess
Datei anzeigen Open project: woocommerce/woocommerce Class Usage Examples

Protected Properties

Property Type Description
$cache_group string A group must be set to to enable caching.
$data array Order Data array. This is the core order data exposed in APIs since 2.7.0.
$meta_type WP defines 'post', 'user', 'comment', and 'term'.
$order object May store an order to prevent retriving it multiple times.

Public Methods

Method Description
__construct ( integer | object | array $item ) Constructor.
get_formatted_meta_data ( string $hideprefix = '_' ) : array Expands things like term slugs before return.
get_name ( string $context = 'view' ) : string Get order item name.
get_order ( ) : integer Get parent order object.
get_order_id ( string $context = 'view' ) : integer Get order ID this meta belongs to.
get_quantity ( ) : integer Get quantity.
get_type ( ) : string Get order item type. Overridden by child classes.
is_type ( $type ) : boolean Type checking
offsetExists ( string $offset ) : boolean offsetExists for ArrayAccess
offsetGet ( string $offset ) : mixed offsetGet for ArrayAccess
offsetSet ( string $offset, mixed $value ) offsetSet for ArrayAccess
offsetUnset ( string $offset ) offsetUnset for ArrayAccess
set_name ( string $value ) Set order item name.
set_order_id ( integer $value ) Set order ID.

Protected Methods

Method Description
get_hook_prefix ( ) : string Prefix for action and filter hooks on data.

Method Details

__construct() public method

Constructor.
public __construct ( integer | object | array $item )
$item integer | object | array ID to load from the DB, or WC_Order_Item Object

get_formatted_meta_data() public method

Expands things like term slugs before return.
public get_formatted_meta_data ( string $hideprefix = '_' ) : array
$hideprefix string (default: _)
return array

get_hook_prefix() protected method

Prefix for action and filter hooks on data.
Since: 2.7.0
protected get_hook_prefix ( ) : string
return string

get_name() public method

Get order item name.
public get_name ( string $context = 'view' ) : string
$context string
return string

get_order() public method

Get parent order object.
public get_order ( ) : integer
return integer

get_order_id() public method

Get order ID this meta belongs to.
public get_order_id ( string $context = 'view' ) : integer
$context string
return integer

get_quantity() public method

Get quantity.
public get_quantity ( ) : integer
return integer

get_type() public method

Get order item type. Overridden by child classes.
public get_type ( ) : string
return string

is_type() public method

Type checking
public is_type ( $type ) : boolean
return boolean

offsetExists() public method

offsetExists for ArrayAccess
public offsetExists ( string $offset ) : boolean
$offset string
return boolean

offsetGet() public method

offsetGet for ArrayAccess
public offsetGet ( string $offset ) : mixed
$offset string
return mixed

offsetSet() public method

offsetSet for ArrayAccess
public offsetSet ( string $offset, mixed $value )
$offset string
$value mixed

offsetUnset() public method

offsetUnset for ArrayAccess
public offsetUnset ( string $offset )
$offset string

set_name() public method

Set order item name.
public set_name ( string $value )
$value string

set_order_id() public method

Set order ID.
public set_order_id ( integer $value )
$value integer

Property Details

$cache_group protected_oe property

A group must be set to to enable caching.
protected string $cache_group
return string

$data protected_oe property

Order Data array. This is the core order data exposed in APIs since 2.7.0.
Since: 2.7.0
protected array $data
return array

$meta_type protected_oe property

WP defines 'post', 'user', 'comment', and 'term'.
protected $meta_type

$order protected_oe property

May store an order to prevent retriving it multiple times.
protected object $order
return object