WooCommerce Code Reference

Functions

Table of Contents

wc_get_screen_ids()  : array<string|int, mixed>
Get all WooCommerce screen ids.
wc_get_page_screen_id()  : string
Get page ID for a specific WC resource.
wc_create_page()  : int
Create a page and store the ID in an option.
woocommerce_admin_fields()  : mixed
Output admin fields.
woocommerce_update_options()  : mixed
Update all settings which are passed.
woocommerce_settings_get_option()  : string
Get a setting from the settings API.
wc_maybe_adjust_line_item_product_stock()  : bool|array<string|int, mixed>|WP_Error
Sees if line item stock has already reduced stock, and whether those values need adjusting e.g. after changing item qty.
wc_save_order_items()  : mixed
Save order items. Uses the CRUD.
wc_render_action_buttons()  : string
Get HTML for some action buttons. Used in list tables.
wc_render_invalid_variation_notice()  : mixed
Shows a notice if variations are missing prices.
woocommerce_wp_text_input()  : mixed
Output a text input box.
woocommerce_wp_hidden_input()  : mixed
Output a hidden input box.
woocommerce_wp_textarea_input()  : mixed
Output a textarea input box.
woocommerce_wp_checkbox()  : mixed
Output a checkbox input box.
woocommerce_wp_select()  : mixed
Output a select input box.
woocommerce_wp_radio()  : mixed
Output a radio input box.
woocommerce_wp_note()  : mixed
Output a note.
wc_admin_number_format()  : string
Format a number using the decimal and thousands separator settings in WooCommerce.
wc_admin_url()  : string
Retrieves a URL to relative path inside WooCommerce admin with the provided query parameters.

Functions

wc_get_page_screen_id()

Get page ID for a specific WC resource.

wc_get_page_screen_id(string $for) : string
Parameters
$for : string

Name of the resource.

wc_create_page()

Create a page and store the ID in an option.

wc_create_page(mixed $slug[, string $option = '' ][, string $page_title = '' ][, string $page_content = '' ], int $post_parent[, string $post_status = 'publish' ]) : int
Parameters
$slug : mixed

Slug for the new page.

$option : string = ''

Option name to store the page's ID.

$page_title : string = ''

(default: '') Title for the new page.

$page_content : string = ''

(default: '') Content for the new page.

$post_parent : int

(default: 0) Parent for the new page.

$post_status : string = 'publish'

(default: publish) The post status of the new page.

woocommerce_admin_fields()

Output admin fields.

woocommerce_admin_fields(array<string|int, mixed> $options) : mixed

Loops through the woocommerce options array and outputs each field.

Parameters
$options : array<string|int, mixed>

Opens array to output.

woocommerce_update_options()

Update all settings which are passed.

woocommerce_update_options(array<string|int, mixed> $options[, array<string|int, mixed> $data = null ]) : mixed
Parameters
$options : array<string|int, mixed>

Option fields to save.

$data : array<string|int, mixed> = null

Passed data.

woocommerce_settings_get_option()

Get a setting from the settings API.

woocommerce_settings_get_option(mixed $option_name[, mixed $default = '' ]) : string
Parameters
$option_name : mixed

Option name to save.

$default : mixed = ''

Default value to save.

wc_maybe_adjust_line_item_product_stock()

Sees if line item stock has already reduced stock, and whether those values need adjusting e.g. after changing item qty.

wc_maybe_adjust_line_item_product_stock(WC_Order_Item $item[, int $item_quantity = -1 ]) : bool|array<string|int, mixed>|WP_Error
Parameters
$item : WC_Order_Item

Item object.

$item_quantity : int = -1

Optional quantity to check against. Read from object if not passed.

Tags
since
3.6.0

wc_save_order_items()

Save order items. Uses the CRUD.

wc_save_order_items(int $order_id, array<string|int, mixed> $items) : mixed
Parameters
$order_id : int

Order ID.

$items : array<string|int, mixed>

Order items to save.

Tags
since
2.2

wc_render_action_buttons()

Get HTML for some action buttons. Used in list tables.

wc_render_action_buttons(array<string|int, mixed> $actions) : string
Parameters
$actions : array<string|int, mixed>

Actions to output.

Tags
since
3.3.0

woocommerce_wp_text_input()

Output a text input box.

woocommerce_wp_text_input(array<string|int, mixed> $field[, WC_Data $data = null ]) : mixed
Parameters
$field : array<string|int, mixed>

Field data.

$data : WC_Data = null

WC_Data object, will be preferred over post object when passed.

woocommerce_wp_hidden_input()

Output a hidden input box.

woocommerce_wp_hidden_input(array<string|int, mixed> $field[, WC_Data $data = null ]) : mixed
Parameters
$field : array<string|int, mixed>

Field data.

$data : WC_Data = null

WC_Data object, will be preferred over post object when passed.

woocommerce_wp_textarea_input()

Output a textarea input box.

woocommerce_wp_textarea_input(array<string|int, mixed> $field[, WC_Data $data = null ]) : mixed
Parameters
$field : array<string|int, mixed>

Field data.

$data : WC_Data = null

WC_Data object, will be preferred over post object when passed.

woocommerce_wp_checkbox()

Output a checkbox input box.

woocommerce_wp_checkbox(array<string|int, mixed> $field[, WC_Data $data = null ]) : mixed
Parameters
$field : array<string|int, mixed>

Field data.

$data : WC_Data = null

WC_Data object, will be preferred over post object when passed.

woocommerce_wp_select()

Output a select input box.

woocommerce_wp_select(array<string|int, mixed> $field[, WC_Data $data = null ]) : mixed
Parameters
$field : array<string|int, mixed>

Field data.

$data : WC_Data = null

WC_Data object, will be preferred over post object when passed.

woocommerce_wp_radio()

Output a radio input box.

woocommerce_wp_radio(array<string|int, mixed> $field[, WC_Data $data = null ]) : mixed
Parameters
$field : array<string|int, mixed>

Field data.

$data : WC_Data = null

WC_Data object, will be preferred over post object when passed.

woocommerce_wp_note()

Output a note.

woocommerce_wp_note(array<string|int, mixed> $field) : mixed
Parameters
$field : array<string|int, mixed>

Field data.

wc_admin_number_format()

Format a number using the decimal and thousands separator settings in WooCommerce.

wc_admin_number_format(mixed $number) : string
Parameters
$number : mixed

Number to be formatted.

wc_admin_url()

Retrieves a URL to relative path inside WooCommerce admin with the provided query parameters.

wc_admin_url([string $path = null ][, array<string|int, mixed> $query = array() ]) : string
Parameters
$path : string = null

Relative path of the desired page.

$query : array<string|int, mixed> = array()

Query parameters to append to the path.