WooCommerce Code Reference

Search results

WC_Post_Data

Post data class.

Table of Contents

$editing_term Editing term. object
init() Hook in methods. mixed
variation_post_link() Link to parent products when getting permalink for variation. string
do_deferred_product_sync() Sync products queued to sync. mixed
deferred_product_sync() Sync a product. mixed
transition_post_status() When a post status changes. mixed
delete_product_query_transients() Delete product view transients when needed e.g. when post status changes, or visibility/stock status is modified. mixed
product_type_changed() Handle type changes. mixed
edit_term() When editing a term, check for product attributes. mixed
edited_term() When a term is edited, check for product attributes and update variations. mixed
update_order_item_metadata() Ensure floats are correctly converted to strings based on PHP locale. null|bool
update_post_metadata() Ensure floats are correctly converted to strings based on PHP locale. null|bool
wp_insert_post_data() Forces the order posts to have a title in a certain format (containing the date). array
filter_oembed_response_data() Change embed data for certain post types. array
delete_post() Removes variations etc belonging to a deleted post, and clears transients. mixed
trash_post() Trash post. mixed
untrash_post() Untrash post. mixed
before_delete_order() Before deleting an order, do some cleanup. mixed
delete_order_items() Remove item meta on permanent deletion. mixed
delete_order_downloadable_permissions() Remove downloadable permissions on permanent order deletion. mixed
flush_object_meta_cache() Flush meta cache for CRUD objects on direct update. mixed
force_default_term() Ensure default category gets set. mixed
sync_product_stock_status() When setting stock level, ensure the stock status is kept in sync. mixed
process_product_file_download_paths() Update changed downloads. mixed
set_object_terms() Delete transients when terms are set. mixed

Properties

Methods

variation_post_link()

Link to parent products when getting permalink for variation.

public static variation_post_link( $permalink : string , $post : WP_Post ) : string
Parameters
$permalink : string

Permalink.

$post : WP_Post

Post data.

Return values
string

do_deferred_product_sync()

Sync products queued to sync.

public static do_deferred_product_sync( ) : mixed
Return values
mixed

deferred_product_sync()

Sync a product.

public static deferred_product_sync( $product_id : int ) : mixed
Parameters
$product_id : int

Product ID.

Return values
mixed

transition_post_status()

When a post status changes.

public static transition_post_status( $new_status : string , $old_status : string , $post : WP_Post ) : mixed
Parameters
$new_status : string

New status.

$old_status : string

Old status.

$post : WP_Post

Post data.

Return values
mixed

delete_product_query_transients()

Delete product view transients when needed e.g. when post status changes, or visibility/stock status is modified.

public static delete_product_query_transients( ) : mixed
Return values
mixed

product_type_changed()

Handle type changes.

public static product_type_changed( $product : WC_Product , $from : string , $to : string ) : mixed
Parameters
$product : WC_Product

Product data.

$from : string

Origin type.

$to : string

New type.

Tags
since
Return values
mixed

edit_term()

When editing a term, check for product attributes.

public static edit_term( $term_id : int , $tt_id : int , $taxonomy : string ) : mixed
Parameters
$term_id : int

Term ID.

$tt_id : int

Term taxonomy ID.

$taxonomy : string

Taxonomy slug.

Return values
mixed

edited_term()

When a term is edited, check for product attributes and update variations.

public static edited_term( $term_id : int , $tt_id : int , $taxonomy : string ) : mixed
Parameters
$term_id : int

Term ID.

$tt_id : int

Term taxonomy ID.

$taxonomy : string

Taxonomy slug.

Return values
mixed

update_order_item_metadata()

Ensure floats are correctly converted to strings based on PHP locale.

public static update_order_item_metadata( $check : null , $object_id : int , $meta_key : string , $meta_value : mixed , $prev_value : mixed ) : null|bool
Parameters
$check : null

Whether to allow updating metadata for the given type.

$object_id : int

Object ID.

$meta_key : string

Meta key.

$meta_value : mixed

Meta value. Must be serializable if non-scalar.

$prev_value : mixed

If specified, only update existing metadata entries with the specified value. Otherwise, update all entries.

Return values
null|bool

update_post_metadata()

Ensure floats are correctly converted to strings based on PHP locale.

public static update_post_metadata( $check : null , $object_id : int , $meta_key : string , $meta_value : mixed , $prev_value : mixed ) : null|bool
Parameters
$check : null

Whether to allow updating metadata for the given type.

$object_id : int

Object ID.

$meta_key : string

Meta key.

$meta_value : mixed

Meta value. Must be serializable if non-scalar.

$prev_value : mixed

If specified, only update existing metadata entries with the specified value. Otherwise, update all entries.

Return values
null|bool

wp_insert_post_data()

Forces the order posts to have a title in a certain format (containing the date).

public static wp_insert_post_data( $data : array ) : array

Forces certain product data based on the product's type, e.g. grouped products cannot have a parent.

Parameters
$data : array

An array of slashed post data.

Return values
array

filter_oembed_response_data()

Change embed data for certain post types.

public static filter_oembed_response_data( $data : array , $post : WP_Post ) : array
Parameters
$data : array

The response data.

$post : WP_Post

The post object.

Tags
since
Return values
array

delete_post()

Removes variations etc belonging to a deleted post, and clears transients.

public static delete_post( $id : mixed ) : mixed
Parameters
$id : mixed

ID of post being deleted.

Return values
mixed

trash_post()

Trash post.

public static trash_post( $id : mixed ) : mixed
Parameters
$id : mixed

Post ID.

Return values
mixed

untrash_post()

Untrash post.

public static untrash_post( $id : mixed ) : mixed
Parameters
$id : mixed

Post ID.

Return values
mixed

before_delete_order()

Before deleting an order, do some cleanup.

public static before_delete_order( $order_id : int ) : mixed
Parameters
$order_id : int

Order ID.

Tags
since
Return values
mixed

delete_order_items()

Remove item meta on permanent deletion.

public static delete_order_items( $postid : int ) : mixed
Parameters
$postid : int

Post ID.

Return values
mixed

delete_order_downloadable_permissions()

Remove downloadable permissions on permanent order deletion.

public static delete_order_downloadable_permissions( $postid : int ) : mixed
Parameters
$postid : int

Post ID.

Return values
mixed

flush_object_meta_cache()

Flush meta cache for CRUD objects on direct update.

public static flush_object_meta_cache( $meta_id : int , $object_id : int , $meta_key : string , $meta_value : string ) : mixed
Parameters
$meta_id : int

Meta ID.

$object_id : int

Object ID.

$meta_key : string

Meta key.

$meta_value : string

Meta value.

Return values
mixed

force_default_term()

Ensure default category gets set.

public static force_default_term( $object_id : int , $terms : array , $tt_ids : array , $taxonomy : string , $append : bool ) : mixed
Parameters
$object_id : int

Product ID.

$terms : array

Terms array.

$tt_ids : array

Term ids array.

$taxonomy : string

Taxonomy name.

$append : bool

Are we appending or setting terms.

Tags
since
Return values
mixed

sync_product_stock_status()

When setting stock level, ensure the stock status is kept in sync.

public static sync_product_stock_status( $meta_id : int , $object_id : int , $meta_key : string , $meta_value : mixed ) : mixed
Parameters
$meta_id : int

Meta ID.

$object_id : int

Object ID.

$meta_key : string

Meta key.

$meta_value : mixed

Meta value.

Tags
deprecated
Return values
mixed

process_product_file_download_paths()

Update changed downloads.

public static process_product_file_download_paths( $product_id : int , $variation_id : int , $downloads : array ) : mixed
Parameters
$product_id : int

Product ID.

$variation_id : int

Variation ID. Optional product variation identifier.

$downloads : array

Newly set files.

Tags
deprecated

No action is necessary on changes to download paths since download_id is no longer based on file hash.

Return values
mixed

set_object_terms()

Delete transients when terms are set.

public static set_object_terms( $object_id : int , $terms : mixed , $tt_ids : array , $taxonomy : string , $append : mixed , $old_tt_ids : array ) : mixed
Parameters
$object_id : int

Object ID.

$terms : mixed

An array of object terms.

$tt_ids : array

An array of term taxonomy IDs.

$taxonomy : string

Taxonomy slug.

$append : mixed

Whether to append new terms to the old terms.

$old_tt_ids : array

Old array of term taxonomy IDs.

Tags
deprecated
Return values
mixed
Back to the top