PHP Class WC_Post_Data

Standardises certain post data on save.
Author: WooThemes
Show file Open project: woocommerce/woocommerce Class Usage Examples

Public Methods

Method Description
deferred_product_sync ( integer $product_id ) Sync a product.
delete_order_downloadable_permissions ( $postid ) Remove downloadable permissions on permanent order deletion.
delete_order_items ( $postid ) Remove item meta on permanent deletion.
delete_post ( mixed $id ) Removes variations etc belonging to a deleted post, and clears transients.
delete_product_query_transients ( ) Delete product view transients when needed e.g. when post status changes, or visibility/stock status is modified.
edit_term ( id $term_id, id $tt_id, string $taxonomy ) When editing a term, check for product attributes.
edited_term ( id $term_id, id $tt_id, string $taxonomy ) When a term is edited, check for product attributes and update variations.
init ( ) Hook in methods.
process_product_file_download_paths ( integer $product_id, integer $variation_id, array $downloads ) Update changed downloads.
set_object_terms ( $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids ) Delete transients when terms are set.
sync_product_stock_status ( integer $meta_id, integer $object_id, string $meta_key, mixed $meta_value ) When setting stock level, ensure the stock status is kept in sync.
transition_post_status ( $new_status, $old_status, $post ) When a post status changes.
trash_post ( mixed $id ) woocommerce_trash_post function.
untrash_post ( mixed $id ) woocommerce_untrash_post function.
update_order_item_metadata ( null $check, integer $object_id, string $meta_key, mixed $meta_value, mixed $prev_value ) : null | boolean Ensure floats are correctly converted to strings based on PHP locale.
update_post_metadata ( null $check, integer $object_id, string $meta_key, mixed $meta_value, mixed $prev_value ) : null | boolean Ensure floats are correctly converted to strings based on PHP locale.
variation_post_link ( $permalink, $post ) : string Link to parent products when getting permalink for variation.
wp_insert_post_data ( array $data ) : array Forces the order posts to have a title in a certain format (containing the date).

Method Details

deferred_product_sync() public static method

Sync a product.
public static deferred_product_sync ( integer $product_id )
$product_id integer

delete_order_downloadable_permissions() public static method

Remove downloadable permissions on permanent order deletion.
public static delete_order_downloadable_permissions ( $postid )

delete_order_items() public static method

Remove item meta on permanent deletion.
public static delete_order_items ( $postid )

delete_post() public static method

Removes variations etc belonging to a deleted post, and clears transients.
public static delete_post ( mixed $id )
$id mixed ID of post being deleted

delete_product_query_transients() public static method

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

edit_term() public static method

When editing a term, check for product attributes.
public static edit_term ( id $term_id, id $tt_id, string $taxonomy )
$term_id id
$tt_id id
$taxonomy string

edited_term() public static method

When a term is edited, check for product attributes and update variations.
public static edited_term ( id $term_id, id $tt_id, string $taxonomy )
$term_id id
$tt_id id
$taxonomy string

init() public static method

Hook in methods.
public static init ( )

process_product_file_download_paths() public static method

Update changed downloads.
public static process_product_file_download_paths ( integer $product_id, integer $variation_id, array $downloads )
$product_id integer product identifier
$variation_id integer optional product variation identifier
$downloads array newly set files

set_object_terms() public static method

Delete transients when terms are set.
public static set_object_terms ( $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids )

sync_product_stock_status() public static method

When setting stock level, ensure the stock status is kept in sync.
Deprecation:
public static sync_product_stock_status ( integer $meta_id, integer $object_id, string $meta_key, mixed $meta_value )
$meta_id integer
$object_id integer
$meta_key string
$meta_value mixed

transition_post_status() public static method

When a post status changes.
public static transition_post_status ( $new_status, $old_status, $post )

trash_post() public static method

woocommerce_trash_post function.
public static trash_post ( mixed $id )
$id mixed

untrash_post() public static method

woocommerce_untrash_post function.
public static untrash_post ( mixed $id )
$id mixed

update_order_item_metadata() public static method

Ensure floats are correctly converted to strings based on PHP locale.
public static update_order_item_metadata ( null $check, integer $object_id, string $meta_key, mixed $meta_value, mixed $prev_value ) : null | boolean
$check null
$object_id integer
$meta_key string
$meta_value mixed
$prev_value mixed
return null | boolean

update_post_metadata() public static method

Ensure floats are correctly converted to strings based on PHP locale.
public static update_post_metadata ( null $check, integer $object_id, string $meta_key, mixed $meta_value, mixed $prev_value ) : null | boolean
$check null
$object_id integer
$meta_key string
$meta_value mixed
$prev_value mixed
return null | boolean

variation_post_link() public static method

Link to parent products when getting permalink for variation.
public static variation_post_link ( $permalink, $post ) : string
return string

wp_insert_post_data() public static method

Forces certain product data based on the product's type, e.g. grouped products cannot have a parent.
public static wp_insert_post_data ( array $data ) : array
$data array
return array