WooCommerce Code Reference

Search results

wc-admin-functions.php

Table of Contents

wc_get_screen_ids() Get all WooCommerce screen ids.
wc_create_page() Create a page and store the ID in an option.
woocommerce_admin_fields() Output admin fields.
woocommerce_update_options() Update all settings which are passed.
woocommerce_settings_get_option() Get a setting from the settings API.
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_save_order_items() Save order items. Uses the CRUD.
wc_render_action_buttons() Get HTML for some action buttons. Used in list tables.
wc_render_invalid_variation_notice() Shows a notice if variations are missing prices.

Functions

wc_get_screen_ids()

Get all WooCommerce screen ids.

wc_get_screen_ids( ) : array
Return values
array

wc_create_page()

Create a page and store the ID in an option.

wc_create_page( $slug : mixed [, $option : string = '' ] [, $page_title : string = '' ] [, $page_content : string = '' ] , $post_parent : int ) : 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.

Return values
int

page ID.

woocommerce_admin_fields()

Output admin fields.

woocommerce_admin_fields( $options : array ) : mixed

Loops through the woocommerce options array and outputs each field.

Parameters
$options : array

Opens array to output.

Return values
mixed

woocommerce_update_options()

Update all settings which are passed.

woocommerce_update_options( $options : array [, $data : array = null ] ) : mixed
Parameters
$options : array

Option fields to save.

$data : array = null

Passed data.

Return values
mixed

woocommerce_settings_get_option()

Get a setting from the settings API.

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

Option name to save.

$default : mixed = ''

Default value to save.

Return values
string

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( $item : WC_Order_Item [, $item_quantity : int = -1 ] ) : bool|array|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
Return values
bool|array|WP_Error

Array of changes or error object when stock is updated (@see wc_update_product_stock). False if nothing changes.

wc_save_order_items()

Save order items. Uses the CRUD.

wc_save_order_items( $order_id : int , $items : array ) : mixed
Parameters
$order_id : int

Order ID.

$items : array

Order items to save.

Tags
since
Return values
mixed

wc_render_action_buttons()

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

wc_render_action_buttons( $actions : array ) : string
Parameters
$actions : array

Actions to output.

Tags
since
Return values
string

wc_render_invalid_variation_notice()

Shows a notice if variations are missing prices.

wc_render_invalid_variation_notice( $product_object : WC_Product ) : mixed
Parameters
$product_object : WC_Product

Product object.

Tags
since
Return values
mixed
Back to the top