PHP Class WC_Data_Store_WP

Contains functions like meta handling for all default data stores. Your own data store doesn't need to use WC_Data_Store_WP -- you can write your own meta handling functions.
Author: WooThemes
Show file Open project: woocommerce/woocommerce

Protected Properties

Property Type Description
$internal_meta_keys array Data stored in meta keys, but not considered "meta" for an object.
$meta_type WP defines 'post', 'user', 'comment', and 'term'.
$object_id_field_for_meta string This should be the name of the field your table uses for associating meta with objects. For example, in payment_tokenmeta, this would be payment_token_id.

Public Methods

Method Description
add_meta ( &$object, $meta ) : meta Add new piece of meta.
delete_meta ( &$object, $meta ) : array Deletes meta based on meta ID.
read_meta ( &$object ) : array Returns an array of meta for an object.
update_meta ( &$object, $meta ) Update meta.

Protected Methods

Method Description
exclude_internal_meta_keys ( object $meta ) : boolean Callback to remove unwanted meta data.
get_db_info ( ) : array Table structure is slightly different between meta types, this function will return what we need to know.
get_term_ids ( $object, string $taxonomy ) : array Get and store terms from a taxonomy.
prefix_key ( $key ) : array Internal meta keys we don't want exposed as part of meta_data. This is in addition to all data props with _ prefix.

Method Details

add_meta() public method

Add new piece of meta.
Since: 2.7.0
public add_meta ( &$object, $meta ) : meta
return meta ID

delete_meta() public method

Deletes meta based on meta ID.
Since: 2.7.0
public delete_meta ( &$object, $meta ) : array
return array

exclude_internal_meta_keys() protected method

Callback to remove unwanted meta data.
protected exclude_internal_meta_keys ( object $meta ) : boolean
$meta object
return boolean

get_db_info() protected method

Table structure is slightly different between meta types, this function will return what we need to know.
Since: 2.7.0
protected get_db_info ( ) : array
return array Array elements: table, object_id_field, meta_id_field

get_term_ids() protected method

Get and store terms from a taxonomy.
Since: 2.7.0
protected get_term_ids ( $object, string $taxonomy ) : array
$taxonomy string Taxonomy name e.g. product_cat
return array of terms

prefix_key() protected method

Internal meta keys we don't want exposed as part of meta_data. This is in addition to all data props with _ prefix.
Since: 2.6.0
protected prefix_key ( $key ) : array
return array

read_meta() public method

Returns an array of meta for an object.
Since: 2.7.0
public read_meta ( &$object ) : array
return array

update_meta() public method

Update meta.
Since: 2.7.0
public update_meta ( &$object, $meta )

Property Details

$internal_meta_keys protected property

Data stored in meta keys, but not considered "meta" for an object.
Since: 2.7.0
protected array $internal_meta_keys
return array

$meta_type protected property

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

$object_id_field_for_meta protected property

This should be the name of the field your table uses for associating meta with objects. For example, in payment_tokenmeta, this would be payment_token_id.
protected string $object_id_field_for_meta
return string