wc_importer_current_locale()
Importer current locale.
wc_importer_current_locale() : string
Importer current locale.
wc_importer_current_locale() : string
Add English mapping placeholders when not using English as current language.
wc_importer_default_english_mappings(array<string|int, mixed> $mappings) : array<string|int, mixed>
Importer columns mappings.
Add English special mapping placeholders when not using English as current language.
wc_importer_default_special_english_mappings(array<string|int, mixed> $mappings) : array<string|int, mixed>
Importer columns mappings.
Add generic mappings.
wc_importer_generic_mappings(array<string|int, mixed> $mappings) : array<string|int, mixed>
Importer columns mappings.
Add Shopify mappings.
wc_importer_shopify_mappings(array<string|int, mixed> $mappings, array<string|int, mixed> $raw_headers) : array<string|int, mixed>
Importer columns mappings.
Raw headers from CSV being imported.
Add special wildcard Shopify mappings.
wc_importer_shopify_special_mappings(array<string|int, mixed> $mappings, array<string|int, mixed> $raw_headers) : array<string|int, mixed>
Importer columns mappings.
Raw headers from CSV being imported.
Expand special Shopify columns to WC format.
wc_importer_shopify_expand_data(array<string|int, mixed> $data) : array<string|int, mixed>
Array of data.
Add mappings for WordPress tables.
wc_importer_wordpress_mappings(array<string|int, mixed> $mappings) : array<string|int, mixed>
Importer columns mappings.
Get all WooCommerce screen ids.
wc_get_screen_ids() : array<string|int, mixed>
Get page ID for a specific WC resource.
wc_get_page_screen_id(string $for) : string
Name of the resource.
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
Slug for the new page.
Option name to store the page's ID.
(default: '') Title for the new page.
(default: '') Content for the new page.
(default: 0) Parent for the new page.
(default: publish) The post status of the new page.
Output admin fields.
woocommerce_admin_fields(array<string|int, mixed> $options) : mixed
Loops through the woocommerce options array and outputs each field.
Opens array to output.
Update all settings which are passed.
woocommerce_update_options(array<string|int, mixed> $options[, array<string|int, mixed> $data = null ]) : mixed
Option fields to save.
Passed data.
Get a setting from the settings API.
woocommerce_settings_get_option(mixed $option_name[, mixed $default = '' ]) : string
Option name to save.
Default value to save.
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
Item object.
Optional quantity to check against. Read from object if not passed.
Save order items. Uses the CRUD.
wc_save_order_items(int $order_id, array<string|int, mixed> $items) : mixed
Order ID.
Order items to save.
Get HTML for some action buttons. Used in list tables.
wc_render_action_buttons(array<string|int, mixed> $actions) : string
Actions to output.
Shows a notice if variations are missing prices.
wc_render_invalid_variation_notice(WC_Product $product_object) : mixed
Product object.
Output a text input box.
woocommerce_wp_text_input(array<string|int, mixed> $field[, WC_Data $data = null ]) : mixed
Field data.
WC_Data object, will be preferred over post object when passed.
Output a hidden input box.
woocommerce_wp_hidden_input(array<string|int, mixed> $field[, WC_Data $data = null ]) : mixed
Field data.
WC_Data object, will be preferred over post object when passed.
Output a textarea input box.
woocommerce_wp_textarea_input(array<string|int, mixed> $field[, WC_Data $data = null ]) : mixed
Field data.
WC_Data object, will be preferred over post object when passed.
Output a checkbox input box.
woocommerce_wp_checkbox(array<string|int, mixed> $field[, WC_Data $data = null ]) : mixed
Field data.
WC_Data object, will be preferred over post object when passed.
Output a select input box.
woocommerce_wp_select(array<string|int, mixed> $field[, WC_Data $data = null ]) : mixed
Field data.
WC_Data object, will be preferred over post object when passed.
Output a radio input box.
woocommerce_wp_radio(array<string|int, mixed> $field[, WC_Data $data = null ]) : mixed
Field data.
WC_Data object, will be preferred over post object when passed.
Output a note.
woocommerce_wp_note(array<string|int, mixed> $field) : mixed
Field data.
Returns core WC pages to connect to WC-Admin.
wc_admin_get_core_pages_to_connect() : array<string|int, mixed>
Filter breadcrumbs for core pages that aren't explicitly connected.
wc_admin_filter_core_page_breadcrumbs(array<string|int, mixed> $breadcrumbs) : array<string|int, mixed>
Breadcrumb pieces.
Render the WC-Admin header bar on all WooCommerce core pages.
wc_admin_connect_core_pages(bool $is_connected, bool $current_page) : bool
Whether the current page is connected.
The current page, if connected.
Format a number using the decimal and thousands separator settings in WooCommerce.
wc_admin_number_format(mixed $number) : string
Number to be formatted.
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
Relative path of the desired page.
Query parameters to append to the path.
wc_admin_get_feature_config() : mixed
Connect an existing page to WooCommerce Admin.
wc_admin_connect_page(array<string|int, mixed> $options) : mixed
Passthrough to PageController::connect_page().
Options for PageController::connect_page().
Register JS-powered WooCommerce Admin Page.
wc_admin_register_page(array<string|int, mixed> $options) : mixed
Passthrough to PageController::register_page().
Options for PageController::register_page().
Is this page connected to WooCommerce Admin? Passthrough to PageController::is_connected_page().
wc_admin_is_connected_page() : bool
Is this a WooCommerce Admin Page? Passthrough to PageController::is_registered_page().
wc_admin_is_registered_page() : bool
Get breadcrumbs for WooCommerce Admin Page navigation.
wc_admin_get_breadcrumbs() : array<string|int, mixed>
Passthrough to PageController::get_breadcrumbs().
Update order stats `status` index length.
wc_admin_update_0201_order_status_index() : mixed
See: https://github.com/woocommerce/woocommerce-admin/issues/2969.
Rename "gross_total" to "total_sales".
wc_admin_update_0230_rename_gross_total() : mixed
See: https://github.com/woocommerce/woocommerce-admin/issues/3175
Remove the note unsnoozing scheduled action.
wc_admin_update_0251_remove_unsnooze_action() : mixed
Remove Facebook Extension note.
wc_admin_update_110_remove_facebook_note() : mixed
Remove Dismiss action from tracking opt-in admin note.
wc_admin_update_130_remove_dismiss_action_from_tracking_opt_in_note() : mixed
Update DB Version.
wc_admin_update_130_db_version() : mixed
Update DB Version.
wc_admin_update_140_db_version() : mixed
Remove Facebook Experts note.
wc_admin_update_160_remove_facebook_note() : mixed
Set "two column" homescreen layout as default for existing stores.
wc_admin_update_170_homescreen_layout() : mixed
Delete the preexisting export files.
wc_admin_update_270_delete_report_downloads() : mixed
Update the old task list options.
wc_admin_update_271_update_task_list_options() : mixed
Update order stats `status`.
wc_admin_update_280_order_status() : mixed
Update the old task list options.
wc_admin_update_290_update_apperance_task_option() : mixed
Delete the old woocommerce_default_homepage_layout option.
wc_admin_update_290_delete_default_homepage_layout_option() : mixed
Use woocommerce_admin_activity_panel_inbox_last_read from the user meta to set wc_admin_notes.is_read col.
wc_admin_update_300_update_is_read_from_last_read() : mixed
Delete "is_primary" column from the wc_admin_notes table.
wc_admin_update_340_remove_is_primary_from_note_action() : mixed
Delete the deprecated remote inbox notifications option since transients are now used.
wc_update_670_delete_deprecated_remote_inbox_notifications_option() : mixed
Returns the url to the lost password endpoint url.
wc_lostpassword_url([string $default_url = '' ]) : string
Default lost password URL.
Get the link to the edit account details page.
wc_customer_edit_account_url() : string
Get the edit address slug translation.
wc_edit_address_i18n(string $id[, bool $flip = false ]) : string
Address ID.
Flip the array to make it possible to retrieve the values ​​from both sides.
Get My Account menu items.
wc_get_account_menu_items() : array<string|int, mixed>
Get account menu item classes.
wc_get_account_menu_item_classes(string $endpoint) : string
Endpoint.
Get account endpoint URL.
wc_get_account_endpoint_url(string $endpoint) : string
Endpoint.
Get My Account > Orders columns.
wc_get_account_orders_columns() : array<string|int, mixed>
Get My Account > Downloads columns.
wc_get_account_downloads_columns() : array<string|int, mixed>
Get My Account > Payment methods columns.
wc_get_account_payment_methods_columns() : array<string|int, mixed>
Get My Account > Payment methods types
wc_get_account_payment_methods_types() : array<string|int, mixed>
Get account orders actions.
wc_get_account_orders_actions(int|WC_Order $order) : array<string|int, mixed>
Order instance or ID.
Get account formatted address.
wc_get_account_formatted_address([string $address_type = 'billing' ], int $customer_id) : string
Type of address; 'billing' or 'shipping'.
Customer ID. Defaults to 0.
Returns an array of a user's saved payments list for output on the account tab.
wc_get_account_saved_payment_methods_list(array<string|int, mixed> $list, int $customer_id) : array<string|int, mixed>
List of payment methods passed from wc_get_customer_saved_methods_list().
The customer to fetch payment methods for.
Controls the output for credit cards on the my account page.
wc_get_account_saved_payment_methods_list_item_cc(array<string|int, mixed> $item, WC_Payment_Token $payment_token) : array<string|int, mixed>
Individual list item from woocommerce_saved_payment_methods_list.
The payment token associated with this method entry.
Controls the output for eChecks on the my account page.
wc_get_account_saved_payment_methods_list_item_echeck(array<string|int, mixed> $item, WC_Payment_Token $payment_token) : array<string|int, mixed>
Individual list item from woocommerce_saved_payment_methods_list.
The payment token associated with this method entry.
Gets text attributes from a string.
wc_get_text_attributes(string $raw_attributes) : array<string|int, mixed>
Raw attributes.
See if an attribute is actually valid.
wc_get_text_attributes_filter_callback(string $value) : bool
Value.
Implode an array of attributes using WC_DELIMITER.
wc_implode_text_attributes(array<string|int, mixed> $attributes) : string
Attributes list.
Get attribute taxonomies.
wc_get_attribute_taxonomies() : array<string|int, mixed>
Get (cached) attribute taxonomy ID and name pairs.
wc_get_attribute_taxonomy_ids() : array<string|int, mixed>
Get (cached) attribute taxonomy label and name pairs.
wc_get_attribute_taxonomy_labels() : array<string|int, mixed>
Get a product attribute name.
wc_attribute_taxonomy_name(string $attribute_name) : string
Attribute name.
Get the attribute name used when storing values in post meta.
wc_variation_attribute_name(string $attribute_name) : string
Attribute name.
Get a product attribute name by ID.
wc_attribute_taxonomy_name_by_id(int $attribute_id) : string
Attribute ID.
Get a product attribute ID by name.
wc_attribute_taxonomy_id_by_name(string $name) : int
Attribute name.
Get a product attributes label.
wc_attribute_label(string $name[, WC_Product $product = '' ]) : string
Attribute name.
Product data.
Get a product attributes orderby setting.
wc_attribute_orderby(string $name) : string
Attribute name.
Get an array of product attribute taxonomies.
wc_get_attribute_taxonomy_names() : array<string|int, mixed>
Get attribute types.
wc_get_attribute_types() : array<string|int, mixed>
Check if there are custom attribute types.
wc_has_custom_attribute_types() : bool
Get attribute type label.
wc_get_attribute_type_label(string $type) : string
Attribute type slug.
Check if attribute name is reserved.
wc_check_if_attribute_name_is_reserved(string $attribute_name) : bool
https://codex.wordpress.org/Function_Reference/register_taxonomy#Reserved_Terms.
Attribute name.
Callback for array filter to get visible only.
wc_attributes_array_filter_visible(WC_Product_Attribute $attribute) : bool
Attribute data.
Callback for array filter to get variation attributes only.
wc_attributes_array_filter_variation(WC_Product_Attribute $attribute) : bool
Attribute data.
Check if an attribute is included in the attributes area of a variation name.
wc_is_attribute_in_product_name(string $attribute, string $name) : bool
Attribute value to check for.
Product name to check in.
Callback for array filter to get default attributes. Will allow for '0' string values, but regard all other class PHP FALSE equivalents normally.
wc_array_filter_default_attributes(mixed $attribute) : bool
Attribute being considered for exclusion from parent array.
Get attribute data by ID.
wc_get_attribute(int $id) : stdClass|null
Attribute ID.
Create attribute.
wc_create_attribute(array<string|int, mixed> $args) : int|WP_Error
Attribute arguments { Array of attribute parameters.
@type int $id Unique identifier, used to update an attribute.
@type string $name Attribute name. Always required.
@type string $slug Attribute alphanumeric identifier.
@type string $type Type of attribute.
Core by default accepts: 'select' and 'text'.
Default to 'select'.
@type string $order_by Sort order.
Accepts: 'menu_order', 'name', 'name_num' and 'id'.
Default to 'menu_order'.
@type bool $has_archives Enable or disable attribute archives. False by default.
}
Update an attribute.
wc_update_attribute(int $id, array<string|int, mixed> $args) : int|WP_Error
For available args see wc_create_attribute().
Attribute ID.
Attribute arguments.
Delete attribute by ID.
wc_delete_attribute(int $id) : bool
Attribute ID.
Get an unprefixed product attribute name.
wc_attribute_taxonomy_slug(string $attribute_name) : string
Attribute name.
Prevent password protected products being added to the cart.
wc_protected_product_add_to_cart(bool $passed, int $product_id) : bool
Validation.
Product ID.
Clears the cart session when called.
wc_empty_cart() : mixed
Load the persistent cart.
wc_load_persistent_cart(string $user_login, WP_User $user) : mixed
User login.
User data.
Retrieves unvalidated referer from '_wp_http_referer' or HTTP referer.
wc_get_raw_referer() : string|false
Do not use for redirects, use {@see} instead.
Add to cart messages.
wc_add_to_cart_message(int|array<string|int, mixed> $products[, bool $show_qty = false ][, bool $return = false ]) : mixed
Product ID list or single product ID.
Should quantities be shown? Added in 2.6.0.
Return message rather than add it.
Comma separate a list of item names, and replace final comma with 'and'.
wc_format_list_of_items(array<string|int, mixed> $items) : string
Cart items.
Clear cart after payment.
wc_clear_cart_after_payment() : mixed
Get the subtotal.
wc_cart_totals_subtotal_html() : mixed
Get shipping methods.
wc_cart_totals_shipping_html() : mixed
Get taxes total.
wc_cart_totals_taxes_total_html() : mixed
Get a coupon label.
wc_cart_totals_coupon_label(string|WC_Coupon $coupon[, bool $echo = true ]) : string
Coupon data or code.
Echo or return.
Get coupon display HTML.
wc_cart_totals_coupon_html(string|WC_Coupon $coupon) : mixed
Coupon data or code.
Get order total html including inc tax if needed.
wc_cart_totals_order_total_html() : mixed
Get the fee value.
wc_cart_totals_fee_html(object $fee) : mixed
Fee data.
Get a shipping methods full label including price.
wc_cart_totals_shipping_method_label(WC_Shipping_Rate $method) : string
Shipping method rate data.
Round discount.
wc_cart_round_discount(float $value, int $precision) : float
Amount to round.
DP to round.
Gets chosen shipping method IDs from chosen_shipping_methods session, without instance IDs.
wc_get_chosen_shipping_method_ids() : array<string|int, string>
Get chosen method for package from session.
wc_get_chosen_shipping_method_for_package(int $key, array<string|int, mixed> $package) : string|bool
Key of package.
Package data array.
Choose the default method for a package.
wc_get_default_shipping_method_for_package(int $key, array<string|int, mixed> $package, string $chosen_method) : string
Key of package.
Package data array.
Chosen shipping method. e.g. flat_rate:1.
See if the methods have changed since the last request.
wc_shipping_methods_have_changed(int $key, array<string|int, mixed> $package) : bool
Key of package.
Package data array.
Gets a hash of important product data that when changed should cause cart items to be invalidated.
wc_get_cart_item_data_hash(WC_Product $product) : string
The woocommerce_cart_item_data_to_validate filter can be used to add custom properties.
Product object.
Is_woocommerce - Returns true if on a page which uses WooCommerce templates (cart and checkout are standard pages with shortcodes and thus are not included).
is_woocommerce() : bool
Is_shop - Returns true when viewing the product type archive (shop).
is_shop() : bool
Is_product_taxonomy - Returns true when viewing a product taxonomy archive.
is_product_taxonomy() : bool
Is_product_category - Returns true when viewing a product category.
is_product_category([string $term = '' ]) : bool
(default: '') The term slug your checking for. Leave blank to return true on any.
Is_product_tag - Returns true when viewing a product tag.
is_product_tag([string $term = '' ]) : bool
(default: '') The term slug your checking for. Leave blank to return true on any.
Is_product - Returns true when viewing a single product.
is_product() : bool
Is_cart - Returns true when viewing the cart page.
is_cart() : bool
Is_checkout - Returns true when viewing the checkout page, or when processing AJAX requests for updating or processing the checkout.
is_checkout() : bool
Is_checkout_pay - Returns true when viewing the checkout's pay page.
is_checkout_pay_page() : bool
Is_wc_endpoint_url - Check if an endpoint is showing.
is_wc_endpoint_url([string|false $endpoint = false ]) : bool
Whether endpoint.
Is_account_page - Returns true when viewing an account page.
is_account_page() : bool
Is_view_order_page - Returns true when on the view order page.
is_view_order_page() : bool
Check for edit account page.
is_edit_account_page() : bool
Returns true when viewing the edit account page.
Is_order_received_page - Returns true when viewing the order received page.
is_order_received_page() : bool
Is_add_payment_method_page - Returns true when viewing the add payment method page.
is_add_payment_method_page() : bool
Is_lost_password_page - Returns true when viewing the lost password page.
is_lost_password_page() : bool
Is_ajax - Returns true when the page is loaded via ajax.
is_ajax() : bool
Is_store_notice_showing - Returns true when store notice is active.
is_store_notice_showing() : bool
Is_filtered - Returns true when filtering products using layered nav or price sliders.
is_filtered() : bool
Returns true when the passed taxonomy name is a product attribute.
taxonomy_is_product_attribute(string $name) : bool
of the attribute.
Returns true when the passed meta name is a product attribute.
meta_is_product_attribute(string $name, string $value, int $product_id) : bool
of the attribute.
of the attribute.
to check for attribute.
Are store-wide taxes enabled?
wc_tax_enabled() : bool
Is shipping enabled?
wc_shipping_enabled() : bool
Are prices inclusive of tax?
wc_prices_include_tax() : bool
Simple check for validating a URL, it must start with http:// or https://.
wc_is_valid_url(string $url) : bool
and pass FILTER_VALIDATE_URL validation.
to check.
Check if the home URL is https. If it is, we don't need to do things such as 'force ssl'.
wc_site_is_https() : bool
Check if the checkout is configured for https. Look at options, WP HTTPS plugin, or the permalink itself.
wc_checkout_is_https() : bool
Checks whether the content passed contains a specific short code.
wc_post_content_has_shortcode([string $tag = '' ]) : bool
Shortcode tag to check.
Check if reviews are enabled.
wc_reviews_enabled() : bool
Check if reviews ratings are enabled.
wc_review_ratings_enabled() : bool
Check if review ratings are required.
wc_review_ratings_required() : bool
Check if a CSV file is valid.
wc_is_file_valid_csv(string $file[, bool $check_path = true ]) : bool
File name.
If should check for the path.
Check if the current theme is a block theme.
wc_current_theme_is_fse_theme() : bool
Check if the current theme has WooCommerce support or is a FSE theme.
wc_current_theme_supports_woocommerce_or_fse() : bool
Given an element name, returns a class name.
wc_wp_theme_get_element_class_name(string $element) : string
If the WP-related function is not defined or current theme is not a FSE theme, return empty string.
The name of the element.
Given an element name, returns true or false depending on whether the current theme has styles for that element defined in theme.json.
wc_block_theme_has_styles_for_element(string $element) : bool
If the theme is not a block theme or the WP-related function is not defined, return false.
The name of the element.
Define a constant if it is not already defined.
wc_maybe_define_constant(string $name, mixed $value) : mixed
Constant name.
Value.
Create a new order programmatically.
wc_create_order([array<string|int, mixed> $args = array() ]) : WC_Order|WP_Error
Returns a new order object on success which can then be used to add additional data.
Order arguments.
Update an order. Uses wc_create_order.
wc_update_order(array<string|int, mixed> $args) : WC_Order|WP_Error
Order arguments.
Given a path, this will convert any of the subpaths into their corresponding tokens.
wc_tokenize_path(string $path, array<string|int, mixed> $path_tokens) : string
The absolute path to tokenize.
An array keyed with the token, containing paths that should be replaced.
Given a tokenized path, this will expand the tokens to their full path.
wc_untokenize_path(string $path, array<string|int, mixed> $path_tokens) : string
The absolute path to expand.
An array keyed with the token, containing paths that should be expanded.
Fetches an array containing all of the configurable path constants to be used in tokenization.
wc_get_path_define_tokens() : array<string|int, mixed>
Get template part (for templates like the shop-loop).
wc_get_template_part(mixed $slug[, string $name = '' ]) : mixed
WC_TEMPLATE_DEBUG_MODE will prevent overrides in themes from taking priority.
Template slug.
Template name (default: '').
Get other templates (e.g. product attributes) passing attributes and including the file.
wc_get_template(string $template_name[, array<string|int, mixed> $args = array() ][, string $template_path = '' ][, string $default_path = '' ]) : mixed
Template name.
Arguments. (default: array).
Template path. (default: '').
Default path. (default: '').
Like wc_get_template, but returns the HTML instead of outputting.
wc_get_template_html(string $template_name[, array<string|int, mixed> $args = array() ][, string $template_path = '' ][, string $default_path = '' ]) : string
Template name.
Arguments. (default: array).
Template path. (default: '').
Default path. (default: '').
Locate a template and return the path for inclusion.
wc_locate_template(string $template_name[, string $template_path = '' ][, string $default_path = '' ]) : string
This is the load order:
yourtheme/$template_path/$template_name yourtheme/$template_name $default_path/$template_name
Template name.
Template path. (default: '').
Default path. (default: '').
Add a template to the template cache.
wc_set_template_cache(string $cache_key, string $template) : mixed
Object cache key.
Located template.
Clear the template cache.
wc_clear_template_cache() : mixed
Get Base Currency Code.
get_woocommerce_currency() : string
Get full list of currency codes.
get_woocommerce_currencies() : array<string|int, mixed>
Currency symbols and names should follow the Unicode CLDR recommendation (https://cldr.unicode.org/translation/currency-names-and-symbols)
Get all available Currency symbols.
get_woocommerce_currency_symbols() : array<string|int, mixed>
Currency symbols and names should follow the Unicode CLDR recommendation (https://cldr.unicode.org/translation/currency-names-and-symbols)
Get Currency symbol.
get_woocommerce_currency_symbol([string $currency = '' ]) : string
Currency symbols and names should follow the Unicode CLDR recommendation (https://cldr.unicode.org/translation/currency-names-and-symbols)
Currency. (default: '').
Send HTML emails from WooCommerce.
wc_mail(mixed $to, mixed $subject, mixed $message[, string $headers = "Content-Type: text/html
" ][, string $attachments = '' ]) : bool
Receiver.
Subject.
Message.
Headers. (default: "Content-Type: text/html\r\n").
Attachments. (default: "").
Return "theme support" values from the current theme, if set.
wc_get_theme_support([string $prop = '' ][, mixed $default = null ]) : mixed
Name of prop (or key::subkey for arrays of props) if you want a specific value. Leave blank to get all props as an array.
Optional value to return if the theme does not declare support for a prop.
Get an image size by name or defined dimensions.
wc_get_image_size(array<string|int, mixed>|string $image_size) : array<string|int, mixed>
The returned variable is filtered by woocommerce_get_image_size_{image_size} filter to allow 3rd party customisation.
Sizes defined by the theme take priority over settings. Settings are hidden when a theme defines sizes.
Name of the image size to get, or an array of dimensions.
Queue some JavaScript code to be output in the footer.
wc_enqueue_js(string $code) : mixed
Code.
Output any queued javascript code in the footer.
wc_print_js() : mixed
Set a cookie - wrapper for setcookie using WP constants.
wc_setcookie(string $name, string $value, int $expire[, bool $secure = false ][, bool $httponly = false ]) : mixed
Name of the cookie being set.
Value of the cookie.
Expiry of the cookie.
Whether the cookie should be served only over https.
Whether the cookie is only accessible over HTTP, not scripting languages like JavaScript. @since 3.6.0.
Get the URL to the WooCommerce Legacy REST API.
get_woocommerce_api_url(string $path) : string
Note that as of WooCommerce 9.0 the WooCommerce Legacy REST API has been moved to a dedicated extension, and the implementation of its root endpoint in WooCommerce core is now just a stub that will always return an error. See the setup_legacy_api_stub method in includes/class-woocommerce.php and: https://developer.woocommerce.com/2023/10/03/the-legacy-rest-api-will-move-to-a-dedicated-extension-in-woocommerce-9-0/
an endpoint to include in the URL.
Recursively get page children.
wc_get_page_children(int $page_id) : array<string|int, int>
Page ID.
Flushes rewrite rules when the shop page (or it's children) gets saved.
flush_rewrite_rules_on_shop_page_save() : mixed
Various rewrite rule fixes.
wc_fix_rewrite_rules(array<string|int, mixed> $rules) : array<string|int, mixed>
Rules.
Prevent product attachment links from breaking when using complex rewrite structures.
wc_fix_product_attachment_link(string $link, int $post_id) : string
Link.
Post ID.
Protect downloads from ms-files.php in multisite.
wc_ms_protect_download_rewite_rules(string $rewrite) : string
rewrite rules.
Formats a string in the format COUNTRY:STATE into an array.
wc_format_country_state_string(string $country_string) : array<string|int, mixed>
Country string.
Get the store's base location.
wc_get_base_location() : array<string|int, mixed>
Get the customer's default location.
wc_get_customer_default_location() : array<string|int, mixed>
Filtered, and set to base location or left blank. If cache-busting, this should only be used when 'location' is set in the querystring.
Get user agent string.
wc_get_user_agent() : string
Generate a rand hash.
wc_rand_hash() : string
WC API - Hash.
wc_api_hash(string $data) : string
Message to be hashed.
Find all possible combinations of values from the input array and return in a logical order.
wc_array_cartesian(array<string|int, mixed> $input) : array<string|int, mixed>
Input.
Run a MySQL transaction query, if supported.
wc_transaction_query([string $type = 'start' ][, bool $force = false ]) : mixed
Types: start (default), commit, rollback.
use of transactions.
Gets the url to the cart page.
wc_get_cart_url() : string
Gets the url to the checkout page.
wc_get_checkout_url() : string
Register a shipping method.
woocommerce_register_shipping_method(string|object $shipping_method) : mixed
class name (string) or a class object.
Get the shipping zone matching a given package from the cart.
wc_get_shipping_zone(array<string|int, mixed> $package) : WC_Shipping_Zone
Shipping package.
Get a nice name for credit card providers.
wc_get_credit_card_type_label(string $type) : string
Provider Slug/Type.
Outputs a "back" link so admin screens can easily jump back a page.
wc_back_link(string $label, string $url) : mixed
Title of the page to return to.
URL of the page to return to.
Display a WooCommerce help tip.
wc_help_tip(string $tip[, bool $allow_html = false ]) : string
Help tip text.
Allow sanitized HTML if true or escape.
Return a list of potential postcodes for wildcard searching.
wc_get_wildcard_postcodes(string $postcode[, string $country = '' ]) : array<string|int, string>
Postcode.
Country to format postcode for matching.
Used by shipping zones and taxes to compare a given $postcode to stored postcodes to find matches for numerical ranges, and wildcards.
wc_postcode_location_matcher(string $postcode, array<string|int, mixed> $objects, string $object_id_key, string $object_compare_key[, string $country = '' ]) : array<string|int, mixed>
Postcode you want to match against stored postcodes.
Array of postcode objects from Database.
DB column name for the ID.
DB column name for the value.
Country from which this postcode belongs. Allows for formatting.
Gets number of shipping methods currently enabled. Used to identify if shipping is configured.
wc_get_shipping_method_count([bool $include_legacy = false ][, bool $enabled_only = false ]) : int
Count legacy shipping methods too.
Whether non-legacy shipping methods should be restricted to enabled ones. It doesn't affect legacy shipping methods. @since 4.3.0.
Wrapper for set_time_limit to see if it is enabled.
wc_set_time_limit(int $limit) : mixed
Time limit.
Wrapper for nocache_headers which also disables page caching.
wc_nocache_headers() : mixed
Used to sort products attributes with uasort.
wc_product_attribute_uasort_comparison(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
First attribute to compare.
Second attribute to compare.
Used to sort shipping zone methods with uasort.
wc_shipping_zone_method_order_uasort_comparison(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
First shipping zone method to compare.
Second shipping zone method to compare.
User to sort checkout fields based on priority with uasort.
wc_checkout_fields_uasort_comparison(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
First field to compare.
Second field to compare.
User to sort two values with ausort.
wc_uasort_comparison(int $a, int $b) : int
First value to compare.
Second value to compare.
Sort values based on ascii, usefull for special chars in strings.
wc_ascii_uasort_comparison(string $a, string $b) : int
First value.
Second value.
Sort array according to current locale rules and maintaining index association.
wc_asort_by_locale(array<string|int, mixed> &$data[, string $locale = '' ]) : array<string|int, mixed>
By default tries to use Collator from PHP Internationalization Functions if available.
If PHP Collator class doesn't exists it fallback to removing accepts from a array
and by sorting with uasort( $data, 'strcmp' )
giving support for ASCII values.
List of values to sort.
Locale.
Get rounding mode for internal tax calculations.
wc_get_tax_rounding_mode() : int
Get rounding precision for internal WC calculations.
wc_get_rounding_precision() : int
Will return the value of wc_get_price_decimals increased by 2 decimals, with WC_ROUNDING_PRECISION being the minimum.
Add precision to a number by moving the decimal point to the right as many places as indicated by wc_get_price_decimals().
wc_add_number_precision(float|null $value[, bool $round = true ]) : int|float
Optionally the result is rounded so that the total number of digits equals wc_get_rounding_precision() plus one.
Number to add precision to.
If the result should be rounded.
Remove precision from a number and return a float.
wc_remove_number_precision(float $value) : float
Number to add precision to.
Add precision to an array of number and return an array of int.
wc_add_number_precision_deep(array<string|int, mixed> $value[, bool $round = true ]) : int|array<string|int, mixed>
Number to add precision to.
Should we round after adding precision?.
Remove precision from an array of number and return an array of int.
wc_remove_number_precision_deep(array<string|int, mixed> $value) : int|array<string|int, mixed>
Number to add precision to.
Get a shared logger instance.
wc_get_logger() : WC_Logger_Interface
Use the woocommerce_logging_class filter to change the logging class. You may provide one of the following:
- a class name which will be instantiated as new $class
with no arguments
- an instance which will be used directly as the logger
In either case, the class or instance must implement WC_Logger_Interface.
Trigger logging cleanup using the logging class.
wc_cleanup_logs() : mixed
Prints human-readable information about a variable.
wc_print_r(mixed $expression[, bool $return = false ]) : string|bool
Some server environments block some debugging functions. This function provides a safe way to turn an expression into a printable, readable form without calling blocked functions.
The expression to be printed.
Optional. Default false. Set to true to return the human-readable string.
Based on wp_list_pluck, this calls a method instead of returning a property.
wc_list_pluck(array<string|int, mixed> $list, int|string $callback_or_field[, int|string $index_key = null ]) : array<string|int, mixed>
List of objects or arrays.
Callback method from the object to place instead of the entire object.
Optional. Field from the object to use as keys for the new array. Default null.
Get permalink settings for things like products and taxonomies.
wc_get_permalink_structure() : array<string|int, mixed>
As of 3.3.0, the permalink settings are stored to the option instead of being blank and inheritting from the locale. This speeds up page loading times by negating the need to switch locales on each page load.
This is more inline with WP core behavior which does not localize slugs.
Switch WooCommerce to site language.
wc_switch_to_site_locale() : mixed
Switch WooCommerce language to original.
wc_restore_locale() : mixed
Convert plaintext phone number to clickable phone number.
wc_make_phone_clickable(string $phone) : string
Remove formatting and allow "+". Example and specs: https://developer.mozilla.org/en/docs/Web/HTML/Element/a#Creating_a_phone_link
Content to convert phone number.
Get an item of post data if set, otherwise return a default value.
wc_get_post_data_by_key(string $key[, string $default = '' ]) : mixed
Meta key.
Default value.
Get data if set, otherwise return a default value or null. Prevents notices when data is not set.
wc_get_var(mixed &$var[, string $default = null ]) : mixed
Variable.
Default value.
Read in WooCommerce headers when reading plugin headers.
wc_enable_wc_plugin_headers(array<string|int, mixed> $headers) : array<string|int, mixed>
Headers.
Prevent auto-updating the WooCommerce plugin on major releases if there are untested extensions active.
wc_prevent_dangerous_auto_updates(bool $should_update, object $plugin) : bool
If should update.
Plugin data.
Delete expired transients.
wc_delete_expired_transients() : int
Deletes all expired transients. The multi-table delete syntax is used. to delete the transient record from table a, and the corresponding. transient_timeout record from table b.
Based on code inside core's upgrade_network() function.
Make a URL relative, if possible.
wc_get_relative_url(string $url) : string
URL to make relative.
See if a resource is remote.
wc_is_external_resource(string $url) : bool
URL to check.
See if theme/s is activate or not.
wc_is_active_theme(string|array<string|int, mixed> $theme) : bool
Theme name or array of theme names to check.
Is the site using a default WP theme?
wc_is_wp_default_theme_active() : bool
Cleans up session data - cron callback.
wc_cleanup_session_data() : mixed
Convert a decimal (e.g. 3.5) to a fraction (e.g. 7/2).
wc_decimal_to_fraction(float $decimal) : array<string|int, mixed>|bool
From: https://www.designedbyaturtle.co.uk/2015/converting-a-decimal-to-a-fraction-in-php/
the decimal number.
Round discount.
wc_round_discount(float $value, int $precision) : float
Amount to round.
DP to round.
Return the html selected attribute if stringified $value is found in array of stringified $options or if stringified $value is the same as scalar stringified $options.
wc_selected(string|int $value, string|int|array<string|int, mixed> $options) : string
Value to find within options.
Options to go through when looking for value.
Retrieves the MySQL server version. Based on $wpdb.
wc_get_server_database_version() : array<string|int, mixed>
Initialize and load the cart functionality.
wc_load_cart() : void
Test whether the context of execution comes from async action scheduler.
wc_is_running_from_async_action_scheduler() : bool
Polyfill for wp_cache_get_multiple for WP versions before 5.5.
wc_cache_get_multiple(array<string|int, mixed> $keys[, string $group = '' ][, bool $force = false ]) : array<string|int, mixed>|bool
Array of keys to get from group.
Optional. Where the cache contents are grouped. Default empty.
Optional. Whether to force an update of the local cache from the persistent cache. Default false.
Get coupon types.
wc_get_coupon_types() : array<string|int, mixed>
Get a coupon type's name.
wc_get_coupon_type([string $type = '' ]) : string
Coupon type.
Coupon types that apply to individual products. Controls which validation rules will apply.
wc_get_product_coupon_types() : array<string|int, mixed>
Coupon types that apply to the cart as a whole. Controls which validation rules will apply.
wc_get_cart_coupon_types() : array<string|int, mixed>
Check if coupons are enabled.
wc_coupons_enabled() : bool
Filterable.
Get coupon code by ID.
wc_get_coupon_code_by_id(int $id) : string
Coupon ID.
Get coupon ID by code.
wc_get_coupon_id_by_code(string $code, int $exclude) : int
Coupon code.
Used to exclude an ID from the check if you're checking existence.
Runs a deprecated action with notice only if used.
wc_do_deprecated_action(string $tag, array<string|int, mixed> $args, string $version[, string $replacement = null ][, string $message = null ]) : mixed
The name of the action hook.
Array of additional function arguments to be passed to do_action().
The version of WooCommerce that deprecated the hook.
The hook that should have been used.
A message regarding the change.
Wrapper for deprecated functions so we can apply some extra logic.
wc_deprecated_function(string $function, string $version[, string $replacement = null ]) : mixed
Function used.
Version the message was added in.
Replacement for the called function.
Wrapper for deprecated hook so we can apply some extra logic.
wc_deprecated_hook(string $hook, string $version[, string $replacement = null ][, string $message = null ]) : mixed
The hook that was used.
The version of WordPress that deprecated the hook.
The hook that should have been used.
A message regarding the change.
When catching an exception, this allows us to log it if unexpected.
wc_caught_exception(Exception $exception_object[, string $function = '' ][, array<string|int, mixed> $args = array() ]) : mixed
The exception object.
The function which threw exception.
The args passed to the function.
Wrapper for _doing_it_wrong().
wc_doing_it_wrong(string $function, string $message, string $version) : mixed
Function used.
Message to log.
Version the message was added in.
Wrapper for deprecated arguments so we can apply some extra logic.
wc_deprecated_argument(string $argument, string $version[, mixed $message = null ]) : mixed
woocommerce_show_messages() : mixed
woocommerce_weekend_area_js() : mixed
woocommerce_tooltip_js() : mixed
woocommerce_datepicker_js() : mixed
woocommerce_admin_scripts() : mixed
woocommerce_create_page(mixed $slug[, mixed $option = '' ][, mixed $page_title = '' ][, mixed $page_content = '' ], mixed $post_parent) : mixed