WooCommerce Code Reference

WC_Admin_Post_Types
in package

WC_Admin_Post_Types Class.

Handles the edit posts views and some functionality on the edit post screen for WC post types.

Table of Contents

__construct()  : mixed
Constructor.
add_display_post_states()  : mixed
Add a post display state for special WC pages in the page list table.
bulk_and_quick_edit_hook()  : mixed
Offers a way to hook into save post without causing an infinite loop when quick/bulk saving product info.
bulk_and_quick_edit_save_post()  : int
Quick and bulk edit saving.
bulk_edit()  : mixed
Custom bulk edit - form.
bulk_edit_save()  : mixed
Bulk edit.
bulk_post_updated_messages()  : array
Specify custom bulk actions messages for different post types.
disable_autosave()  : mixed
Disable the auto-save functionality for Orders.
edit_form_after_title()  : mixed
Print coupon description textarea field.
edit_form_top()  : mixed
Output extra data on post forms.
enter_title_here()  : string
Change title boxes in admin.
hidden_meta_boxes()  : array
Hidden default Meta-Boxes.
hide_cpt_archive_templates()  : array
When editing the shop page, we should hide templates.
post_updated_messages()  : array
Change messages when a post type is updated.
process_product_file_download_paths()  : mixed
Grant downloadable file access to any newly added files on any existing.
product_data_visibility()  : mixed
Output product visibility options.
quick_edit()  : mixed
Custom quick edit - form.
setup_screen()  : mixed
Looks at the current screen and loads the correct list table handler.
show_cpt_archive_notice()  : mixed
Show a notice above the CPT archive.
unique_filename()  : string
Change filename to append random text.
update_filename()  : string
Change filename for WooCommerce uploads and prepend unique chars for security.
upload_dir()  : array
Change upload dir for downloadable files.
woocommerce_media_upload_downloadable_product()  : mixed
Run a filter when uploading a downloadable product.
request_data()  : array
Get the current request data ($_REQUEST superglobal).
maybe_update_stock_status()  : WC_Product
Apply product type constraints to stock status.
quick_edit_save()  : mixed
Quick edit.
set_new_price()  : bool
Set the new regular or sale price if requested.

Methods

add_display_post_states()

Add a post display state for special WC pages in the page list table.

public add_display_post_states(array $post_states, WP_Post $post) : mixed
Parameters
$post_states : array

An array of post display states.

$post : WP_Post

The current post object.

Return values
mixed

bulk_and_quick_edit_hook()

Offers a way to hook into save post without causing an infinite loop when quick/bulk saving product info.

public bulk_and_quick_edit_hook(int $post_id, object $post) : mixed
Parameters
$post_id : int

Post ID being saved.

$post : object

Post object being saved.

Tags
since
3.0.0
Return values
mixed

bulk_and_quick_edit_save_post()

Quick and bulk edit saving.

public bulk_and_quick_edit_save_post(int $post_id, object $post) : int
Parameters
$post_id : int

Post ID being saved.

$post : object

Post object being saved.

Return values
int

bulk_edit()

Custom bulk edit - form.

public bulk_edit(string $column_name, string $post_type) : mixed
Parameters
$column_name : string

Column being shown.

$post_type : string

Post type being shown.

Return values
mixed

bulk_post_updated_messages()

Specify custom bulk actions messages for different post types.

public bulk_post_updated_messages(array $bulk_messages, array $bulk_counts) : array
Parameters
$bulk_messages : array

Array of messages.

$bulk_counts : array

Array of how many objects were updated.

Return values
array

edit_form_after_title()

Print coupon description textarea field.

public edit_form_after_title(WP_Post $post) : mixed
Parameters
$post : WP_Post

Current post object.

Return values
mixed

enter_title_here()

Change title boxes in admin.

public enter_title_here(string $text, WP_Post $post) : string
Parameters
$text : string

Text to shown.

$post : WP_Post

Current post object.

Return values
string

hidden_meta_boxes()

Hidden default Meta-Boxes.

public hidden_meta_boxes(array $hidden, object $screen) : array
Parameters
$hidden : array

Hidden boxes.

$screen : object

Current screen.

Return values
array

hide_cpt_archive_templates()

When editing the shop page, we should hide templates.

public hide_cpt_archive_templates(array $page_templates, string $theme, WP_Post $post) : array
Parameters
$page_templates : array

Templates array.

$theme : string

Classname.

$post : WP_Post

The current post object.

Return values
array

post_updated_messages()

Change messages when a post type is updated.

public post_updated_messages(array $messages) : array
Parameters
$messages : array

Array of messages.

Return values
array

process_product_file_download_paths()

Grant downloadable file access to any newly added files on any existing.

public process_product_file_download_paths(int $product_id, int $variation_id, array $downloadable_files) : mixed

orders for this product that have previously been granted downloadable file access.

Parameters
$product_id : int

product identifier.

$variation_id : int

optional product variation identifier.

$downloadable_files : array

newly set files.

Tags
deprecated
3.3.0

and moved to post-data class.

Return values
mixed

quick_edit()

Custom quick edit - form.

public quick_edit(string $column_name, string $post_type) : mixed
Parameters
$column_name : string

Column being shown.

$post_type : string

Post type being shown.

Return values
mixed

show_cpt_archive_notice()

Show a notice above the CPT archive.

public show_cpt_archive_notice(WP_Post $post) : mixed
Parameters
$post : WP_Post

The current post object.

Return values
mixed

unique_filename()

Change filename to append random text.

public unique_filename(string $full_filename, string $ext) : string
Parameters
$full_filename : string

Original filename with extension.

$ext : string

Extension.

Return values
stringModified filename.

update_filename()

Change filename for WooCommerce uploads and prepend unique chars for security.

public update_filename(string $full_filename, string $ext, string $dir) : string
Parameters
$full_filename : string

Original filename.

$ext : string

Extension of file.

$dir : string

Directory path.

Tags
since
4.0
Return values
stringNew filename with unique hash.

woocommerce_media_upload_downloadable_product()

Run a filter when uploading a downloadable product.

public woocommerce_media_upload_downloadable_product() : mixed
Return values
mixed

request_data()

Get the current request data ($_REQUEST superglobal).

protected request_data() : array

This method is added to ease unit testing.

Return values
arrayThe $_REQUEST superglobal.

maybe_update_stock_status()

Apply product type constraints to stock status.

private maybe_update_stock_status(WC_Product $product, string|null $stock_status) : WC_Product
Parameters
$product : WC_Product

The product whose stock status will be adjusted.

$stock_status : string|null

The stock status to use for adjustment, or null if no new stock status has been supplied in the request.

Return values
WC_ProductThe supplied product, or the synced product if it was a variable product.

set_new_price()

Set the new regular or sale price if requested.

private set_new_price(WC_Product $product, string $price_type) : bool
Parameters
$product : WC_Product

The product to set the new price for.

$price_type : string

'regular' or 'sale'.

Return values
booltrue if a new price has been set, false otherwise.