WooCommerce Code Reference

Functions

Table of Contents

wc_lostpassword_url()  : string
Returns the url to the lost password endpoint url.
wc_customer_edit_account_url()  : string
Get the link to the edit account details page.
wc_edit_address_i18n()  : string
Get the edit address slug translation.
wc_get_account_menu_items()  : array<string|int, mixed>
Get My Account menu items.
wc_get_account_menu_item_classes()  : string
Get account menu item classes.
wc_get_account_endpoint_url()  : string
Get account endpoint URL.
wc_get_account_orders_columns()  : array<string|int, mixed>
Get My Account > Orders columns.
wc_get_account_downloads_columns()  : array<string|int, mixed>
Get My Account > Downloads columns.
wc_get_account_payment_methods_columns()  : array<string|int, mixed>
Get My Account > Payment methods columns.
wc_get_account_payment_methods_types()  : array<string|int, mixed>
Get My Account > Payment methods types
wc_get_account_orders_actions()  : array<string|int, mixed>
Get account orders actions.
wc_get_account_formatted_address()  : string
Get account formatted address.
wc_get_account_saved_payment_methods_list()  : array<string|int, mixed>
Returns an array of a user's saved payments list for output on the account tab.
wc_get_account_saved_payment_methods_list_item_cc()  : array<string|int, mixed>
Controls the output for credit cards on the my account page.
wc_get_account_saved_payment_methods_list_item_echeck()  : array<string|int, mixed>
Controls the output for eChecks on the my account page.
wc_get_text_attributes()  : array<string|int, mixed>
Gets text attributes from a string.
wc_get_text_attributes_filter_callback()  : bool
See if an attribute is actually valid.
wc_implode_text_attributes()  : string
Implode an array of attributes using WC_DELIMITER.
wc_get_attribute_taxonomies()  : array<string|int, mixed>
Get attribute taxonomies.
wc_get_attribute_taxonomy_ids()  : array<string|int, mixed>
Get (cached) attribute taxonomy ID and name pairs.
wc_get_attribute_taxonomy_labels()  : array<string|int, mixed>
Get (cached) attribute taxonomy label and name pairs.
wc_attribute_taxonomy_name()  : string
Get a product attribute name.
wc_variation_attribute_name()  : string
Get the attribute name used when storing values in post meta.
wc_attribute_taxonomy_name_by_id()  : string
Get a product attribute name by ID.
wc_attribute_taxonomy_id_by_name()  : int
Get a product attribute ID by name.
wc_attribute_label()  : string
Get a product attributes label.
wc_attribute_orderby()  : string
Get a product attributes orderby setting.
wc_get_attribute_taxonomy_names()  : array<string|int, mixed>
Get an array of product attribute taxonomies.
wc_get_attribute_types()  : array<string|int, mixed>
Get attribute types.
wc_has_custom_attribute_types()  : bool
Check if there are custom attribute types.
wc_get_attribute_type_label()  : string
Get attribute type label.
wc_check_if_attribute_name_is_reserved()  : bool
Check if attribute name is reserved.
wc_attributes_array_filter_visible()  : bool
Callback for array filter to get visible only.
wc_attributes_array_filter_variation()  : bool
Callback for array filter to get variation attributes only.
wc_is_attribute_in_product_name()  : bool
Check if an attribute is included in the attributes area of a variation name.
wc_array_filter_default_attributes()  : bool
Callback for array filter to get default attributes. Will allow for '0' string values, but regard all other class PHP FALSE equivalents normally.
wc_get_attribute()  : stdClass|null
Get attribute data by ID.
wc_create_attribute()  : int|WP_Error
Create attribute.
wc_update_attribute()  : int|WP_Error
Update an attribute.
wc_delete_attribute()  : bool
Delete attribute by ID.
wc_attribute_taxonomy_slug()  : string
Get an unprefixed product attribute name.
wc_protected_product_add_to_cart()  : bool
Prevent password protected products being added to the cart.
wc_empty_cart()  : mixed
Clears the cart session when called.
wc_load_persistent_cart()  : mixed
Load the persistent cart.
wc_get_raw_referer()  : string|false
Retrieves unvalidated referer from '_wp_http_referer' or HTTP referer.
wc_add_to_cart_message()  : mixed
Add to cart messages.
wc_format_list_of_items()  : string
Comma separate a list of item names, and replace final comma with 'and'.
wc_clear_cart_after_payment()  : mixed
Clear cart after payment.
wc_cart_totals_subtotal_html()  : mixed
Get the subtotal.
wc_cart_totals_shipping_html()  : mixed
Get shipping methods.
wc_cart_totals_taxes_total_html()  : mixed
Get taxes total.
wc_cart_totals_coupon_label()  : string
Get a coupon label.
wc_cart_totals_coupon_html()  : mixed
Get coupon display HTML.
wc_cart_totals_order_total_html()  : mixed
Get order total html including inc tax if needed.
wc_cart_totals_fee_html()  : mixed
Get the fee value.
wc_cart_totals_shipping_method_label()  : string
Get a shipping methods full label including price.
wc_cart_round_discount()  : float
Round discount.
wc_get_chosen_shipping_method_ids()  : array<string|int, string>
Gets chosen shipping method IDs from chosen_shipping_methods session, without instance IDs.
wc_get_chosen_shipping_method_for_package()  : string|bool
Get chosen method for package from session.
wc_get_default_shipping_method_for_package()  : string
Choose the default method for a package.
wc_shipping_methods_have_changed()  : bool
See if the methods have changed since the last request.
wc_get_cart_item_data_hash()  : string
Gets a hash of important product data that when changed should cause cart items to be invalidated.
is_woocommerce()  : bool
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_shop()  : bool
Is_shop - Returns true when viewing the product type archive (shop).
is_product_taxonomy()  : bool
Is_product_taxonomy - Returns true when viewing a product taxonomy archive.
is_product_category()  : bool
Is_product_category - Returns true when viewing a product category.
is_product_tag()  : bool
Is_product_tag - Returns true when viewing a product tag.
is_product()  : bool
Is_product - Returns true when viewing a single product.
is_cart()  : bool
Is_cart - Returns true when viewing the cart page.
is_checkout()  : bool
Is_checkout - Returns true when viewing the checkout page, or when processing AJAX requests for updating or processing the checkout.
is_checkout_pay_page()  : bool
Is_checkout_pay - Returns true when viewing the checkout's pay page.
is_wc_endpoint_url()  : bool
Is_wc_endpoint_url - Check if an endpoint is showing.
is_account_page()  : bool
Is_account_page - Returns true when viewing an account page.
is_view_order_page()  : bool
Is_view_order_page - Returns true when on the view order page.
is_edit_account_page()  : bool
Check for edit account page.
is_order_received_page()  : bool
Is_order_received_page - Returns true when viewing the order received page.
is_add_payment_method_page()  : bool
Is_add_payment_method_page - Returns true when viewing the add payment method page.
is_lost_password_page()  : bool
Is_lost_password_page - Returns true when viewing the lost password page.
is_ajax()  : bool
Is_ajax - Returns true when the page is loaded via ajax.
is_store_notice_showing()  : bool
Is_store_notice_showing - Returns true when store notice is active.
is_filtered()  : bool
Is_filtered - Returns true when filtering products using layered nav or price sliders.
taxonomy_is_product_attribute()  : bool
Returns true when the passed taxonomy name is a product attribute.
meta_is_product_attribute()  : bool
Returns true when the passed meta name is a product attribute.
wc_tax_enabled()  : bool
Are store-wide taxes enabled?
wc_shipping_enabled()  : bool
Is shipping enabled?
wc_prices_include_tax()  : bool
Are prices inclusive of tax?
wc_is_valid_url()  : bool
Simple check for validating a URL, it must start with http:// or https://.
wc_site_is_https()  : bool
Check if the home URL is https. If it is, we don't need to do things such as 'force ssl'.
wc_checkout_is_https()  : bool
Check if the checkout is configured for https. Look at options, WP HTTPS plugin, or the permalink itself.
wc_post_content_has_shortcode()  : bool
Checks whether the content passed contains a specific short code.
wc_reviews_enabled()  : bool
Check if reviews are enabled.
wc_review_ratings_enabled()  : bool
Check if reviews ratings are enabled.
wc_review_ratings_required()  : bool
Check if review ratings are required.
wc_is_file_valid_csv()  : bool
Check if a CSV file is valid.
wc_current_theme_is_fse_theme()  : bool
Check if the current theme is a block theme.
wc_current_theme_supports_woocommerce_or_fse()  : bool
Check if the current theme has WooCommerce support or is a FSE theme.
wc_wp_theme_get_element_class_name()  : string
Given an element name, returns a class name.
wc_block_theme_has_styles_for_element()  : bool
Given an element name, returns true or false depending on whether the current theme has styles for that element defined in theme.json.
wc_maybe_define_constant()  : mixed
Define a constant if it is not already defined.
wc_create_order()  : WC_Order|WP_Error
Create a new order programmatically.
wc_update_order()  : WC_Order|WP_Error
Update an order. Uses wc_create_order.
wc_tokenize_path()  : string
Given a path, this will convert any of the subpaths into their corresponding tokens.
wc_untokenize_path()  : string
Given a tokenized path, this will expand the tokens to their full path.
wc_get_path_define_tokens()  : array<string|int, mixed>
Fetches an array containing all of the configurable path constants to be used in tokenization.
wc_get_template_part()  : mixed
Get template part (for templates like the shop-loop).
wc_get_template()  : mixed
Get other templates (e.g. product attributes) passing attributes and including the file.
wc_get_template_html()  : string
Like wc_get_template, but returns the HTML instead of outputting.
wc_locate_template()  : string
Locate a template and return the path for inclusion.
wc_set_template_cache()  : mixed
Add a template to the template cache.
wc_clear_template_cache()  : mixed
Clear the template cache.
get_woocommerce_currency()  : string
Get Base Currency Code.
get_woocommerce_currencies()  : array<string|int, mixed>
Get full list of currency codes.
get_woocommerce_currency_symbols()  : array<string|int, mixed>
Get all available Currency symbols.
get_woocommerce_currency_symbol()  : string
Get Currency symbol.
wc_mail()  : bool
Send HTML emails from WooCommerce.
wc_get_theme_support()  : mixed
Return "theme support" values from the current theme, if set.
wc_get_image_size()  : array<string|int, mixed>
Get an image size by name or defined dimensions.
wc_enqueue_js()  : mixed
Queue some JavaScript code to be output in the footer.
wc_print_js()  : mixed
Output any queued javascript code in the footer.
wc_setcookie()  : mixed
Set a cookie - wrapper for setcookie using WP constants.
get_woocommerce_api_url()  : string
Get the URL to the WooCommerce Legacy REST API.
wc_get_page_children()  : array<string|int, int>
Recursively get page children.
flush_rewrite_rules_on_shop_page_save()  : mixed
Flushes rewrite rules when the shop page (or it's children) gets saved.
wc_fix_rewrite_rules()  : array<string|int, mixed>
Various rewrite rule fixes.
wc_fix_product_attachment_link()  : string
Prevent product attachment links from breaking when using complex rewrite structures.
wc_ms_protect_download_rewite_rules()  : string
Protect downloads from ms-files.php in multisite.
wc_format_country_state_string()  : array<string|int, mixed>
Formats a string in the format COUNTRY:STATE into an array.
wc_get_base_location()  : array<string|int, mixed>
Get the store's base location.
wc_get_customer_default_location()  : array<string|int, mixed>
Get the customer's default location.
wc_get_user_agent()  : string
Get user agent string.
wc_rand_hash()  : string
Generate a rand hash.
wc_api_hash()  : string
WC API - Hash.
wc_array_cartesian()  : array<string|int, mixed>
Find all possible combinations of values from the input array and return in a logical order.
wc_transaction_query()  : mixed
Run a MySQL transaction query, if supported.
wc_get_cart_url()  : string
Gets the url to the cart page.
wc_get_checkout_url()  : string
Gets the url to the checkout page.
woocommerce_register_shipping_method()  : mixed
Register a shipping method.
wc_get_shipping_zone()  : WC_Shipping_Zone
Get the shipping zone matching a given package from the cart.
wc_get_credit_card_type_label()  : string
Get a nice name for credit card providers.
wc_back_link()  : mixed
Outputs a "back" link so admin screens can easily jump back a page.
wc_help_tip()  : string
Display a WooCommerce help tip.
wc_get_wildcard_postcodes()  : array<string|int, string>
Return a list of potential postcodes for wildcard searching.
wc_postcode_location_matcher()  : array<string|int, mixed>
Used by shipping zones and taxes to compare a given $postcode to stored postcodes to find matches for numerical ranges, and wildcards.
wc_get_shipping_method_count()  : int
Gets number of shipping methods currently enabled. Used to identify if shipping is configured.
wc_set_time_limit()  : mixed
Wrapper for set_time_limit to see if it is enabled.
wc_nocache_headers()  : mixed
Wrapper for nocache_headers which also disables page caching.
wc_product_attribute_uasort_comparison()  : int
Used to sort products attributes with uasort.
wc_shipping_zone_method_order_uasort_comparison()  : int
Used to sort shipping zone methods with uasort.
wc_checkout_fields_uasort_comparison()  : int
User to sort checkout fields based on priority with uasort.
wc_uasort_comparison()  : int
User to sort two values with ausort.
wc_ascii_uasort_comparison()  : int
Sort values based on ascii, usefull for special chars in strings.
wc_asort_by_locale()  : array<string|int, mixed>
Sort array according to current locale rules and maintaining index association.
wc_get_tax_rounding_mode()  : int
Get rounding mode for internal tax calculations.
wc_get_rounding_precision()  : int
Get rounding precision for internal WC calculations.
wc_add_number_precision()  : int|float
Add precision to a number by moving the decimal point to the right as many places as indicated by wc_get_price_decimals().
wc_remove_number_precision()  : float
Remove precision from a number and return a float.
wc_add_number_precision_deep()  : int|array<string|int, mixed>
Add precision to an array of number and return an array of int.
wc_remove_number_precision_deep()  : int|array<string|int, mixed>
Remove precision from an array of number and return an array of int.
wc_get_logger()  : WC_Logger_Interface
Get a shared logger instance.
wc_cleanup_logs()  : mixed
Trigger logging cleanup using the logging class.
wc_print_r()  : string|bool
Prints human-readable information about a variable.
wc_list_pluck()  : array<string|int, mixed>
Based on wp_list_pluck, this calls a method instead of returning a property.
wc_get_permalink_structure()  : array<string|int, mixed>
Get permalink settings for things like products and taxonomies.
wc_switch_to_site_locale()  : mixed
Switch WooCommerce to site language.
wc_restore_locale()  : mixed
Switch WooCommerce language to original.
wc_make_phone_clickable()  : string
Convert plaintext phone number to clickable phone number.
wc_get_post_data_by_key()  : mixed
Get an item of post data if set, otherwise return a default value.
wc_get_var()  : mixed
Get data if set, otherwise return a default value or null. Prevents notices when data is not set.
wc_enable_wc_plugin_headers()  : array<string|int, mixed>
Read in WooCommerce headers when reading plugin headers.
wc_prevent_dangerous_auto_updates()  : bool
Prevent auto-updating the WooCommerce plugin on major releases if there are untested extensions active.
wc_delete_expired_transients()  : int
Delete expired transients.
wc_get_relative_url()  : string
Make a URL relative, if possible.
wc_is_external_resource()  : bool
See if a resource is remote.
wc_is_active_theme()  : bool
See if theme/s is activate or not.
wc_is_wp_default_theme_active()  : bool
Is the site using a default WP theme?
wc_cleanup_session_data()  : mixed
Cleans up session data - cron callback.
wc_decimal_to_fraction()  : array<string|int, mixed>|bool
Convert a decimal (e.g. 3.5) to a fraction (e.g. 7/2).
wc_round_discount()  : float
Round discount.
wc_selected()  : string
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_get_server_database_version()  : array<string|int, mixed>
Retrieves the MySQL server version. Based on $wpdb.
wc_load_cart()  : void
Initialize and load the cart functionality.
wc_is_running_from_async_action_scheduler()  : bool
Test whether the context of execution comes from async action scheduler.
wc_cache_get_multiple()  : array<string|int, mixed>|bool
Polyfill for wp_cache_get_multiple for WP versions before 5.5.
wc_get_coupon_types()  : array<string|int, mixed>
Get coupon types.
wc_get_coupon_type()  : string
Get a coupon type's name.
wc_get_product_coupon_types()  : array<string|int, mixed>
Coupon types that apply to individual products. Controls which validation rules will apply.
wc_get_cart_coupon_types()  : array<string|int, mixed>
Coupon types that apply to the cart as a whole. Controls which validation rules will apply.
wc_coupons_enabled()  : bool
Check if coupons are enabled.
wc_get_coupon_code_by_id()  : string
Get coupon code by ID.
wc_get_coupon_id_by_code()  : int
Get coupon ID by code.
wc_do_deprecated_action()  : mixed
Runs a deprecated action with notice only if used.
wc_deprecated_function()  : mixed
Wrapper for deprecated functions so we can apply some extra logic.
wc_deprecated_hook()  : mixed
Wrapper for deprecated hook so we can apply some extra logic.
wc_caught_exception()  : mixed
When catching an exception, this allows us to log it if unexpected.
wc_doing_it_wrong()  : mixed
Wrapper for _doing_it_wrong().
wc_deprecated_argument()  : mixed
Wrapper for deprecated arguments so we can apply some extra logic.
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
woocommerce_readfile_chunked()  : mixed
woocommerce_format_total()  : string
Formal total costs - format to the number of decimal places for the base currency.
woocommerce_get_formatted_product_name()  : string
Get product name with extra details such as SKU price and attributes. Used within admin.
woocommerce_legacy_paypal_ipn()  : mixed
Handle IPN requests for the legacy paypal gateway by calling gateways manually if needed.
get_product()  : mixed
woocommerce_protected_product_add_to_cart()  : mixed
woocommerce_empty_cart()  : mixed
woocommerce_load_persistent_cart()  : mixed
woocommerce_add_to_cart_message()  : mixed
woocommerce_clear_cart_after_payment()  : mixed
woocommerce_cart_totals_subtotal_html()  : mixed
woocommerce_cart_totals_shipping_html()  : mixed
woocommerce_cart_totals_coupon_html()  : mixed
woocommerce_cart_totals_order_total_html()  : mixed
woocommerce_cart_totals_fee_html()  : mixed
woocommerce_cart_totals_shipping_method_label()  : mixed
woocommerce_get_template_part()  : mixed
woocommerce_get_template()  : mixed
woocommerce_locate_template()  : mixed
woocommerce_mail()  : mixed
woocommerce_disable_admin_bar()  : mixed
woocommerce_create_new_customer()  : mixed
woocommerce_set_customer_auth_cookie()  : mixed
woocommerce_update_new_customer_past_orders()  : mixed
woocommerce_paying_customer()  : mixed
woocommerce_customer_bought_product()  : mixed
woocommerce_customer_has_capability()  : mixed
woocommerce_sanitize_taxonomy_name()  : mixed
woocommerce_get_filename_from_url()  : mixed
woocommerce_get_dimension()  : mixed
woocommerce_get_weight()  : mixed
woocommerce_trim_zeros()  : mixed
woocommerce_round_tax_total()  : mixed
woocommerce_format_decimal()  : mixed
woocommerce_clean()  : mixed
woocommerce_array_overlay()  : mixed
woocommerce_price()  : mixed
woocommerce_let_to_num()  : mixed
woocommerce_date_format()  : mixed
woocommerce_time_format()  : mixed
woocommerce_timezone_string()  : mixed
woocommerce_rgb_from_hex()  : mixed
woocommerce_hex_darker()  : mixed
woocommerce_hex_lighter()  : mixed
woocommerce_light_or_dark()  : mixed
woocommerce_format_hex()  : mixed
woocommerce_get_order_id_by_order_key()  : mixed
woocommerce_downloadable_file_permission()  : mixed
woocommerce_downloadable_product_permissions()  : mixed
woocommerce_add_order_item()  : mixed
woocommerce_delete_order_item()  : mixed
woocommerce_update_order_item_meta()  : mixed
woocommerce_add_order_item_meta()  : mixed
woocommerce_delete_order_item_meta()  : mixed
woocommerce_get_order_item_meta()  : mixed
woocommerce_cancel_unpaid_orders()  : mixed
woocommerce_processing_order_count()  : mixed
woocommerce_get_page_id()  : mixed
woocommerce_get_endpoint_url()  : mixed
woocommerce_lostpassword_url()  : mixed
woocommerce_customer_edit_account_url()  : mixed
woocommerce_nav_menu_items()  : mixed
woocommerce_nav_menu_item_classes()  : mixed
woocommerce_list_pages()  : mixed
woocommerce_product_dropdown_categories()  : mixed
woocommerce_walk_category_dropdown_tree()  : mixed
woocommerce_taxonomy_metadata_wpdbfix()  : mixed
wc_taxonomy_metadata_wpdbfix()  : mixed
woocommerce_order_terms()  : mixed
woocommerce_set_term_order()  : mixed
woocommerce_terms_clauses()  : mixed
_woocommerce_term_recount()  : mixed
woocommerce_recount_after_stock_change()  : mixed
woocommerce_change_term_counts()  : mixed
woocommerce_get_product_ids_on_sale()  : mixed
woocommerce_get_featured_product_ids()  : mixed
woocommerce_get_product_terms()  : mixed
woocommerce_product_post_type_link()  : mixed
woocommerce_placeholder_img_src()  : mixed
woocommerce_placeholder_img()  : mixed
woocommerce_get_formatted_variation()  : mixed
woocommerce_scheduled_sales()  : mixed
woocommerce_get_attachment_image_attributes()  : mixed
woocommerce_prepare_attachment_for_js()  : mixed
woocommerce_track_product_view()  : mixed
woocommerce_compile_less_styles()  : mixed
woocommerce_calc_shipping_backwards_compatibility()  : string
woocommerce_calc_shipping was an option used to determine if shipping was enabled prior to version 2.6.0. This has since been replaced with wc_shipping_enabled() function and the woocommerce_ship_to_countries setting.
woocommerce_get_product_schema()  : string
_wc_save_product_price()  : mixed
Save product price.
wc_get_customer_avatar_url()  : string
Return customer avatar URL.
wc_get_core_supported_themes()  : array<string|int, string>
WooCommerce Core Supported Themes.
wc_get_min_max_price_meta_query()  : array<string|int, mixed>
Get min/max price meta query args.
wc_taxonomy_metadata_update_content_for_split_terms()  : mixed
When a term is split, ensure meta data maintained.
update_woocommerce_term_meta()  : bool
WooCommerce Term Meta API.
add_woocommerce_term_meta()  : bool
WooCommerce Term Meta API.
delete_woocommerce_term_meta()  : bool
WooCommerce Term Meta API
get_woocommerce_term_meta()  : mixed
WooCommerce Term Meta API
wc_register_default_log_handler()  : array<string|int, mixed>
Registers the default log handler.
wc_get_log_file_path()  : string
Get a log file path.
wc_get_log_file_name()  : string
Get a log file name.
wc_string_to_bool()  : bool
Converts a string (e.g. 'yes' or 'no') to a bool.
wc_bool_to_string()  : string
Converts a bool to a 'yes' or 'no'.
wc_string_to_array()  : array<string|int, mixed>
Explode a string into an array by $delimiter and remove empty values.
wc_sanitize_taxonomy_name()  : string
Sanitize taxonomy names. Slug format (no spaces, lowercase).
wc_sanitize_permalink()  : string
Sanitize permalink values before insertion into DB.
wc_get_filename_from_url()  : string
Gets the filename part of a download URL.
wc_get_dimension()  : float
Normalise dimensions, unify to cm then convert to wanted unit value.
wc_get_weight()  : float
Normalise weights, unify to kg then convert to wanted unit value.
wc_trim_zeros()  : string
Trim trailing zeros off prices.
wc_round_tax_total()  : float
Round a tax amount.
wc_legacy_round_half_down()  : float
Round half down in PHP 5.2.
wc_format_refund_total()  : float
Make a refund total negative.
wc_format_decimal()  : string
Format decimal numbers ready for DB storage.
wc_float_to_string()  : string
Convert a float to a string without locale formatting which PHP adds when changing floats to strings.
wc_format_localized_price()  : string
Format a price with WC Currency Locale settings.
wc_format_localized_decimal()  : string
Format a decimal with the decimal separator for prices or PHP Locale settings.
wc_format_coupon_code()  : string
Format a coupon code.
wc_sanitize_coupon_code()  : string
Sanitize a coupon code.
wc_clean()  : string|array<string|int, mixed>
Clean variables using sanitize_text_field. Arrays are cleaned recursively.
wc_check_invalid_utf8()  : string|array<string|int, mixed>
Function wp_check_invalid_utf8 with recursive array support.
wc_sanitize_textarea()  : string
Run wc_clean over posted textarea but maintain line breaks.
wc_sanitize_tooltip()  : string
Sanitize a string destined to be a tooltip.
wc_array_overlay()  : array<string|int, mixed>
Merge two arrays.
wc_stock_amount()  : int|float
Formats a stock amount by running it through a filter.
get_woocommerce_price_format()  : string
Get the price format depending on the currency position.
wc_get_price_thousand_separator()  : string
Return the thousand separator for prices.
wc_get_price_decimal_separator()  : string
Return the decimal separator for prices.
wc_get_price_decimals()  : int
Return the number of decimals after the decimal point.
wc_price()  : string
Format the price with a currency symbol.
wc_let_to_num()  : int
Notation to numbers.
wc_date_format()  : string
WooCommerce Date Format - Allows to change date format for everything WooCommerce.
wc_time_format()  : string
WooCommerce Time Format - Allows to change time format for everything WooCommerce.
wc_string_to_timestamp()  : int
Convert mysql datetime to PHP timestamp, forcing UTC. Wrapper for strtotime.
wc_string_to_datetime()  : WC_DateTime
Convert a date string to a WC_DateTime.
wc_timezone_string()  : string
WooCommerce Timezone - helper to retrieve the timezone string for a site until.
wc_timezone_offset()  : float
Get timezone offset in seconds.
wc_flatten_meta_callback()  : mixed
Callback which can flatten post meta (gets the first value if it's an array).
wc_rgb_from_hex()  : array<string|int, mixed>
Convert RGB to HEX.
wc_hex_darker()  : string
Make HEX color darker.
wc_hex_lighter()  : string
Make HEX color lighter.
wc_hex_is_light()  : bool
Determine whether a hex color is light.
wc_light_or_dark()  : string
Detect if we should use a light or dark color on a background color.
wc_format_hex()  : string|null
Format string as hex.
wc_format_postcode()  : string
Format the postcode according to the country and length of the postcode.
wc_normalize_postcode()  : string
Normalize postcodes.
wc_format_phone_number()  : string
Format phone numbers.
wc_sanitize_phone_number()  : string
Sanitize phone number.
wc_strtoupper()  : string
Wrapper for mb_strtoupper which see's if supported first.
wc_strtolower()  : string
Make a string lowercase.
wc_trim_string()  : string
Trim a string and append a suffix.
wc_format_content()  : string
Format content to display shortcodes.
wc_format_product_short_description()  : string
Format product short description.
wc_format_option_price_separators()  : string
Formats curency symbols when saved in settings.
wc_format_option_price_num_decimals()  : string
Formats decimals when saved in settings.
wc_format_option_hold_stock_minutes()  : string
Formats hold stock option and sets cron event up.
wc_sanitize_term_text_based()  : string
Sanitize terms from an attribute text based.
wc_make_numeric_postcode()  : string
Make numeric postcode.
wc_format_stock_for_display()  : string
Format the stock amount ready for display based on settings.
wc_format_stock_quantity_for_display()  : string
Format the stock quantity ready for display.
wc_format_sale_price()  : string
Format a sale price for display.
wc_format_price_range()  : string
Format a price range for display.
wc_format_weight()  : string
Format a weight for display.
wc_format_dimensions()  : string
Format dimensions for display.
wc_format_datetime()  : string
Format a date for output.
wc_do_oembeds()  : string
Process oEmbeds.
wc_get_string_before_colon()  : string
Get part of a string before :.
wc_array_merge_recursive_numeric()  : array<string|int, mixed>
Array merge and sum function.
wc_implode_html_attributes()  : string
Implode and escape HTML attributes for output.
wc_esc_json()  : string
Escape JSON for use on HTML or attribute text nodes.
wc_parse_relative_date_option()  : array<string|int, mixed>
Parse a relative date option from the settings API into a standard format.
wc_sanitize_endpoint_slug()  : string
Format the endpoint slug, strip out anything not allowed in a url.
wc_notice_count()  : int
Get the count of notices added, either for all notices (default) or for one.
wc_has_notice()  : bool
Check if a notice has already been added.
wc_add_notice()  : mixed
Add and store a notice.
wc_set_notices()  : mixed
Set all notices at once.
wc_clear_notices()  : mixed
Unset all notices.
wc_print_notices()  : string|void
Prints messages and errors which are stored in the session, then clears them.
wc_print_notice()  : mixed
Print a single notice immediately.
wc_get_notices()  : array<string|int, array<string|int, mixed>>
Returns all queued notices, optionally filtered by a notice type.
wc_add_wp_error_notices()  : mixed
Add notices for WP Errors.
wc_kses_notice()  : string
Filters out the same tags as wp_kses_post, but allows tabindex for <a> element.
wc_get_notice_data_attr()  : string
Get notice data attribute.
wc_get_orders()  : array<string|int, WC_Order>|stdClass
Standard way of retrieving orders based on certain parameters.
wc_get_order()  : bool|WC_Order|WC_Order_Refund
Main function for returning orders, uses the WC_Order_Factory class.
wc_get_order_statuses()  : array<string|int, mixed>
Get all order statuses.
wc_is_order_status()  : bool
See if a string is an order status.
wc_get_is_paid_statuses()  : array<string|int, mixed>
Get list of statuses which are consider 'paid'.
wc_get_is_pending_statuses()  : array<string|int, mixed>
Get list of statuses which are consider 'pending payment'.
wc_get_order_status_name()  : string
Get the nice name for an order status.
wc_generate_order_key()  : string
Generate an order key with prefix.
wc_get_order_id_by_order_key()  : int
Finds an Order ID based on an order key.
wc_get_order_types()  : array<string|int, mixed>
Get all registered order types.
wc_get_order_type()  : bool|array<string|int, mixed>
Get an order type by post type name.
wc_register_order_type()  : bool
Register order type. Do not use before init.
wc_processing_order_count()  : int
Return the count of processing orders.
wc_orders_count()  : int
Return the orders count of a specific order status.
wc_downloadable_file_permission()  : int|bool
Grant downloadable product access to the file identified by $download_id.
wc_downloadable_product_permissions()  : mixed
Order Status completed - give downloadable product access to customer.
wc_delete_shop_order_transients()  : mixed
Clear all transients cache for order data.
wc_ship_to_billing_address_only()  : bool
See if we only ship to billing addresses.
wc_create_refund()  : WC_Order_Refund|WP_Error
Create a new order refund programmatically.
wc_refund_payment()  : bool|WP_Error
Try to refund the payment for an order via the gateway.
wc_restock_refunded_items()  : mixed
Restock items during refund.
wc_get_tax_class_by_tax_id()  : string
Get tax class by tax id.
wc_get_payment_gateway_by_order()  : WC_Payment_Gateway|bool
Get payment gateway class by order data.
wc_order_fully_refunded()  : mixed
When refunding an order, create a refund line item if the partial refunds do not match order total.
wc_order_search()  : array<string|int, mixed>
Search orders.
wc_update_total_sales_counts()  : mixed
Update total sales amount for each product within a paid order.
wc_update_coupon_usage_counts()  : mixed
Update used coupon amount for each coupon within an order.
wc_cancel_unpaid_orders()  : mixed
Cancel all unpaid orders after held duration to prevent stock lock for those products.
wc_sanitize_order_id()  : mixed
Sanitize order id removing unwanted characters.
wc_get_order_note()  : stdClass|null
Get an order note.
wc_get_order_notes()  : array<string|int, stdClass>
Get order notes.
wc_create_order_note()  : int|WP_Error
Create an order note.
wc_delete_order_note()  : bool
Delete an order note.
wc_add_order_item()  : int|bool
Add a item to an order (for example a line item).
wc_update_order_item()  : bool
Update an item for an order.
wc_delete_order_item()  : bool
Delete an item from the order it belongs to based on item id.
wc_update_order_item_meta()  : bool
WooCommerce Order Item Meta API - Update term meta.
wc_add_order_item_meta()  : int
WooCommerce Order Item Meta API - Add term meta.
wc_delete_order_item_meta()  : bool
WooCommerce Order Item Meta API - Delete term meta.
wc_get_order_item_meta()  : mixed
WooCommerce Order Item Meta API - Get term meta.
wc_get_order_id_by_order_item_id()  : int
Get order ID by order item ID.
wc_page_endpoint_title()  : string
Replace a page title with the endpoint title.
wc_get_page_id()  : int
Retrieve page ids - used for myaccount, edit_address, shop, cart, checkout, pay, view_order, terms. returns -1 if no page is found.
wc_get_page_permalink()  : string
Retrieve page permalink.
wc_get_endpoint_url()  : string
Get endpoint URL.
wc_nav_menu_items()  : array<string|int, mixed>
Hide menu items conditionally.
wc_nav_menu_item_classes()  : array<string|int, mixed>
Fix active class in nav for shop page.
wc_list_pages()  : string
Fix active class in wp_list_pages for shop page.
wc_get_products()  : array<string|int, mixed>|stdClass
Standard way of retrieving products based on certain parameters.
wc_get_product()  : WC_Product|null|false
Main function for returning products, uses the WC_Product_Factory class.
wc_get_product_object()  : WC_Product
Get a product object.
wc_product_sku_enabled()  : bool
Returns whether or not SKUS are enabled.
wc_product_weight_enabled()  : bool
Returns whether or not product weights are enabled.
wc_product_dimensions_enabled()  : bool
Returns whether or not product dimensions (HxWxD) are enabled.
wc_delete_product_transients()  : mixed
Clear transient cache for product data.
wc_get_product_ids_on_sale()  : array<string|int, mixed>
Function that returns an array containing the IDs of the products that are on sale.
wc_get_featured_product_ids()  : array<string|int, mixed>
Function that returns an array containing the IDs of the featured products.
wc_product_post_type_link()  : string
Filter to allow product_cat in the permalinks for products.
wc_placeholder_img_src()  : string
Get the placeholder image URL either from media, or use the fallback image.
wc_placeholder_img()  : string
Get the placeholder image.
wc_get_formatted_variation()  : string
Variation Formatting.
wc_scheduled_sales()  : mixed
Function which handles the start and end of scheduled sales via cron.
wc_get_attachment_image_attributes()  : array<string|int, mixed>
Get attachment image attributes.
wc_prepare_attachment_for_js()  : array<string|int, mixed>
Prepare attachment for JavaScript.
wc_track_product_view()  : mixed
Track product views.
wc_get_product_types()  : array<string|int, mixed>
Get product types.
wc_product_has_unique_sku()  : bool
Check if product sku is unique.
wc_product_force_unique_sku()  : mixed
Force a unique SKU.
wc_product_generate_unique_sku()  : string
Recursively appends a suffix until a unique SKU is found.
wc_get_product_id_by_sku()  : int
Get product ID by SKU.
wc_get_product_variation_attributes()  : array<string|int, mixed>
Get attributes/data for an individual variation from the database and maintain it's integrity.
wc_get_product_cat_ids()  : array<string|int, mixed>
Get all product cats for a product by ID, including hierarchy
wc_get_product_attachment_props()  : array<string|int, mixed>
Gets data about an attachment, such as alt text and captions.
wc_get_product_visibility_options()  : array<string|int, mixed>
Get product visibility options.
wc_get_product_tax_class_options()  : array<string|int, mixed>
Get product tax class options.
wc_get_product_stock_status_options()  : array<string|int, mixed>
Get stock status options.
wc_get_product_backorder_options()  : array<string|int, mixed>
Get backorder options.
wc_get_related_products()  : array<string|int, mixed>
Get related products based on product category and tags.
wc_get_product_term_ids()  : array<string|int, mixed>
Retrieves product term ids for a taxonomy.
wc_get_price_including_tax()  : float|string
For a given product, and optionally price/qty, work out the price with tax included, based on store settings.
wc_get_price_excluding_tax()  : float|string
For a given product, and optionally price/qty, work out the price with tax excluded, based on store settings.
wc_get_price_to_display()  : float
Returns the price including or excluding tax.
wc_get_product_category_list()  : string
Returns the product categories in a list.
wc_get_product_tag_list()  : string
Returns the product tags in a list.
wc_products_array_filter_visible()  : bool
Callback for array filter to get visible only.
wc_products_array_filter_visible_grouped()  : bool
Callback for array filter to get visible grouped products only.
wc_products_array_filter_editable()  : bool
Callback for array filter to get products the user can edit only.
wc_products_array_filter_readable()  : bool
Callback for array filter to get products the user can view only.
wc_products_array_orderby()  : array<string|int, mixed>
Sort an array of products by a value.
wc_products_array_orderby_title()  : int
Sort by title.
wc_products_array_orderby_id()  : int
Sort by id.
wc_products_array_orderby_date()  : int
Sort by date.
wc_products_array_orderby_modified()  : int
Sort by modified.
wc_products_array_orderby_menu_order()  : int
Sort by menu order.
wc_products_array_orderby_price()  : int
Sort by price low to high.
wc_deferred_product_sync()  : mixed
Queue a product for syncing at the end of the request.
wc_update_product_lookup_tables_is_running()  : bool
See if the lookup table is being generated already.
wc_update_product_lookup_tables()  : mixed
Populate lookup table data for products.
wc_update_product_lookup_tables_column()  : mixed
Populate lookup table column data.
wc_update_product_lookup_tables_rating_count()  : mixed
Populate rating count lookup table data for products.
wc_update_product_lookup_tables_rating_count_batch()  : mixed
Populate a batch of rating count lookup table data for products.
wc_product_attach_featured_image()  : void
Attach product featured image. Use image filename to match a product sku when product is not provided.
wc_rest_prepare_date_response()  : string|null
Parses and formats a date for ISO8601/RFC3339.
wc_rest_allowed_image_mime_types()  : array<string|int, mixed>
Returns image mime types users are allowed to upload via the API.
wc_rest_upload_image_from_url()  : array<string|int, mixed>|WP_Error
Upload image from URL.
wc_rest_set_uploaded_image_as_attachment()  : int
Set uploaded image as attachment.
wc_rest_validate_reports_request_arg()  : WP_Error|bool
Validate reports request arguments.
wc_rest_urlencode_rfc3986()  : string|array<string|int, mixed>
Encodes a value according to RFC 3986.
wc_rest_check_post_permissions()  : bool
Check permissions of posts on REST API.
wc_rest_check_user_permissions()  : bool
Check permissions of users on REST API.
wc_rest_check_product_term_permissions()  : bool
Check permissions of product terms on REST API.
wc_rest_check_manager_permissions()  : bool
Check manager permissions on REST API.
wc_rest_check_product_reviews_permissions()  : bool
Check product reviews permissions on REST API.
wc_rest_is_from_product_editor()  : bool
Returns true if the current REST request is from the product editor.
wc_update_product_stock()  : bool|int|null
Update a product's stock amount.
wc_update_product_stock_status()  : mixed
Update a product's stock status.
wc_maybe_reduce_stock_levels()  : mixed
When a payment is complete, we can reduce stock levels for items within an order.
wc_maybe_increase_stock_levels()  : mixed
When a payment is cancelled, restore stock.
wc_reduce_stock_levels()  : mixed
Reduce stock levels for items within an order, if stock has not already been reduced for the items.
wc_trigger_stock_change_notifications()  : mixed
After stock change events, triggers emails and adds order notes.
wc_increase_stock_levels()  : mixed
Increase stock levels for items within an order.
wc_get_held_stock_quantity()  : int
See how much stock is being held in pending orders.
wc_reserve_stock_for_order()  : mixed
Hold stock for an order.
wc_release_stock_for_order()  : mixed
Release held stock for an order.
wc_get_low_stock_amount()  : int
Return low stock amount to determine if notification needs to be sent
wc_template_redirect()  : mixed
Handle redirects before content is output - hooked into template_redirect so is_page works.
wc_send_frame_options_header()  : mixed
When loading sensitive checkout or account pages, send a HTTP header to limit rendering of pages to same origin iframes for security reasons.
wc_prevent_endpoint_indexing()  : mixed
No index our endpoints.
wc_prevent_adjacent_posts_rel_link_wp_head()  : mixed
Remove adjacent_posts_rel_link_wp_head - pointless for products.
wc_gallery_noscript()  : mixed
Show the gallery if JS is disabled.
wc_setup_product_data()  : WC_Product
When the_post is called, put product data into a global.
wc_setup_loop()  : mixed
Sets up the woocommerce_loop global from the passed args or from the main query.
wc_reset_loop()  : mixed
Resets the woocommerce_loop global.
wc_get_loop_prop()  : mixed
Gets a property from the woocommerce_loop global.
wc_set_loop_prop()  : mixed
Sets a property in the woocommerce_loop global.
wc_set_loop_product_visibility()  : mixed
Set the current visbility for a product in the woocommerce_loop global.
wc_get_loop_product_visibility()  : bool|null
Gets the cached current visibility for a product from the woocommerce_loop global.
woocommerce_product_loop()  : bool
Should the WooCommerce loop be displayed?
wc_generator_tag()  : string
Output generator tag to aid debugging.
wc_body_class()  : array<string|int, mixed>
Add body classes for WC pages.
wc_no_js()  : mixed
NO JS handling.
wc_product_cat_class()  : mixed
Display the classes for the product cat div.
wc_get_default_products_per_row()  : int
Get the default columns setting - this is how many products will be shown per row in loops.
wc_get_default_product_rows_per_page()  : int
Get the default rows setting - this is how many product rows will be shown in loops.
wc_reset_product_grid_settings()  : mixed
Reset the product grid settings when a new theme is activated.
wc_get_loop_class()  : string
Get classname for woocommerce loops.
wc_get_product_cat_class()  : array<string|int, mixed>
Get the classes for the product cat div.
wc_product_post_class()  : array<string|int, mixed>
Adds extra post classes for products via the WordPress post_class hook, if used.
wc_get_product_taxonomy_class()  : array<string|int, mixed>
Get product taxonomy HTML classes.
wc_get_product_class()  : array<string|int, mixed>
Retrieves the classes for the post div as an array.
wc_product_class()  : mixed
Display the classes for the product div.
wc_query_string_form_fields()  : string
Outputs hidden form inputs for each query string variable.
wc_terms_and_conditions_page_id()  : int
Get the terms and conditions page ID.
wc_privacy_policy_page_id()  : int
Get the privacy policy page ID.
wc_terms_and_conditions_checkbox_enabled()  : bool
See if the checkbox is enabled or not based on the existence of the terms page and checkbox text.
wc_get_terms_and_conditions_checkbox_text()  : string
Get the terms and conditions checkbox text, if set.
wc_get_privacy_policy_text()  : string
Get the privacy policy text, if set.
wc_terms_and_conditions_checkbox_text()  : mixed
Output t&c checkbox text.
wc_terms_and_conditions_page_content()  : mixed
Output t&c page's content (if set). The page can be set from checkout settings.
wc_checkout_privacy_policy_text()  : mixed
Render privacy policy text on the checkout.
wc_registration_privacy_policy_text()  : mixed
Render privacy policy text on the register forms.
wc_privacy_policy_text()  : mixed
Output privacy policy text. This is custom text which can be added via the customizer/privacy settings section.
wc_replace_policy_page_link_placeholders()  : string
Replaces placeholders with links to WooCommerce policy pages.
woocommerce_content()  : mixed
Output WooCommerce content.
woocommerce_output_content_wrapper()  : mixed
Output the start of the page wrapper.
woocommerce_output_content_wrapper_end()  : mixed
Output the end of the page wrapper.
woocommerce_get_sidebar()  : mixed
Get the shop sidebar template.
woocommerce_demo_store()  : mixed
Adds a demo store banner to the site if enabled.
woocommerce_page_title()  : string
Page Title function.
woocommerce_product_loop_start()  : string
Output the start of a product loop. By default this is a UL.
woocommerce_product_loop_end()  : string
Output the end of a product loop. By default this is a UL.
woocommerce_template_loop_product_title()  : mixed
Show the product title in the product loop. By default this is an H2.
woocommerce_template_loop_category_title()  : mixed
Show the subcategory title in the product loop.
woocommerce_template_loop_product_link_open()  : mixed
Insert the opening anchor tag for products in the loop.
woocommerce_template_loop_product_link_close()  : mixed
Insert the closing anchor tag for products in the loop.
woocommerce_template_loop_category_link_open()  : mixed
Insert the opening anchor tag for categories in the loop.
woocommerce_template_loop_category_link_close()  : mixed
Insert the closing anchor tag for categories in the loop.
woocommerce_product_taxonomy_archive_header()  : mixed
Output the products header on taxonomy archives.
woocommerce_taxonomy_archive_description()  : mixed
Show an archive description on taxonomy archives.
woocommerce_product_archive_description()  : mixed
Show a shop page description on product archives.
woocommerce_template_loop_add_to_cart()  : mixed
Get the add to cart template for the loop.
woocommerce_template_loop_product_thumbnail()  : mixed
Get the product thumbnail for the loop.
woocommerce_template_loop_price()  : mixed
Get the product price for the loop.
woocommerce_template_loop_rating()  : mixed
Display the average rating in the loop.
woocommerce_show_product_loop_sale_flash()  : mixed
Get the sale flash for the loop.
woocommerce_get_product_thumbnail()  : string
Get the product thumbnail, or the placeholder if not set.
woocommerce_result_count()  : mixed
Output the result count text (Showing x - x of x results).
woocommerce_catalog_ordering()  : mixed
Output the product sorting options.
woocommerce_pagination()  : mixed
Output the pagination.
woocommerce_show_product_images()  : mixed
Output the product image before the single product summary.
woocommerce_show_product_thumbnails()  : mixed
Output the product thumbnails.
wc_get_gallery_image_html()  : string
Get HTML for a gallery image.
woocommerce_output_product_data_tabs()  : mixed
Output the product tabs.
woocommerce_template_single_title()  : mixed
Output the product title.
woocommerce_template_single_rating()  : mixed
Output the product rating.
woocommerce_template_single_price()  : mixed
Output the product price.
woocommerce_template_single_excerpt()  : mixed
Output the product short description (excerpt).
woocommerce_template_single_meta()  : mixed
Output the product meta.
woocommerce_template_single_sharing()  : mixed
Output the product sharing.
woocommerce_show_product_sale_flash()  : mixed
Output the product sale flash.
woocommerce_template_single_add_to_cart()  : mixed
Trigger the single product add to cart action.
woocommerce_simple_add_to_cart()  : mixed
Output the simple product add to cart area.
woocommerce_grouped_add_to_cart()  : mixed
Output the grouped product add to cart area.
woocommerce_variable_add_to_cart()  : mixed
Output the variable product add to cart area.
woocommerce_external_add_to_cart()  : mixed
Output the external product add to cart area.
woocommerce_quantity_input()  : string
Output the quantity input for add to cart forms.
woocommerce_product_description_tab()  : mixed
Output the description tab content.
woocommerce_product_additional_information_tab()  : mixed
Output the attributes tab content.
woocommerce_default_product_tabs()  : array<string|int, mixed>
Add default product tabs to product pages.
woocommerce_sort_product_tabs()  : array<string|int, mixed>
Sort tabs by priority.
woocommerce_comments()  : mixed
Output the Review comments template.
woocommerce_review_display_gravatar()  : void
Display the review authors gravatar
woocommerce_review_display_rating()  : void
Display the reviewers star rating
woocommerce_review_display_meta()  : void
Display the review authors meta (name, verified owner, review date)
woocommerce_review_display_comment_text()  : mixed
Display the review content.
woocommerce_output_related_products()  : mixed
Output the related products.
woocommerce_related_products()  : mixed
Output the related products.
woocommerce_upsell_display()  : mixed
Output product up sells.
woocommerce_shipping_calculator()  : mixed
Output the cart shipping calculator.
woocommerce_cart_totals()  : mixed
Output the cart totals.
woocommerce_cross_sell_display()  : mixed
Output the cart cross-sells.
woocommerce_button_proceed_to_checkout()  : mixed
Output the proceed to checkout button.
woocommerce_widget_shopping_cart_button_view_cart()  : mixed
Output the view cart button.
woocommerce_widget_shopping_cart_proceed_to_checkout()  : mixed
Output the proceed to checkout button.
woocommerce_widget_shopping_cart_subtotal()  : mixed
Output to view cart subtotal.
woocommerce_mini_cart()  : mixed
Output the Mini-cart - used by cart widget.
woocommerce_login_form()  : mixed
Output the WooCommerce Login Form.
woocommerce_checkout_login_form()  : mixed
Output the WooCommerce Checkout Login Form.
woocommerce_breadcrumb()  : mixed
Output the WooCommerce Breadcrumb.
woocommerce_order_review()  : mixed
Output the Order review table for the checkout.
woocommerce_checkout_payment()  : mixed
Output the Payment Methods on the checkout.
woocommerce_checkout_coupon_form()  : mixed
Output the Coupon form for the checkout.
woocommerce_products_will_display()  : bool
Check if we will be showing products or not (and not sub-categories only).
woocommerce_get_loop_display_mode()  : string
See what is going to display in the loop.
woocommerce_maybe_show_product_subcategories()  : string
Maybe display categories before, or instead of, a product loop.
woocommerce_product_subcategories()  : null|bool
This is a legacy function which used to check if we needed to display subcats and then output them. It was called by templates.
woocommerce_output_product_categories()  : bool
Display product sub categories as thumbnails.
woocommerce_get_product_subcategories()  : array<string|int, mixed>
Get (and cache) product subcategories.
woocommerce_subcategory_thumbnail()  : mixed
Show subcategory thumbnails.
woocommerce_order_details_table()  : mixed
Displays order details in a table.
woocommerce_order_downloads_table()  : mixed
Displays order downloads in a table.
woocommerce_order_again_button()  : mixed
Display an 'order again' button on the view order page.
woocommerce_form_field()  : string
Outputs a checkout/address form field.
get_product_search_form()  : string
Display product search form.
woocommerce_output_auth_header()  : mixed
Output the Auth header.
woocommerce_output_auth_footer()  : mixed
Output the Auth footer.
woocommerce_single_variation()  : mixed
Output placeholders for the single variation.
woocommerce_single_variation_add_to_cart_button()  : mixed
Output the add to cart button for variations.
wc_dropdown_variation_attribute_options()  : mixed
Output a list of variation attributes for use in the cart forms.
woocommerce_account_content()  : mixed
My Account content output.
woocommerce_account_navigation()  : mixed
My Account navigation template.
woocommerce_account_orders()  : mixed
My Account > Orders template.
woocommerce_account_view_order()  : mixed
My Account > View order template.
woocommerce_account_downloads()  : mixed
My Account > Downloads template.
woocommerce_account_edit_address()  : mixed
My Account > Edit address template.
woocommerce_account_payment_methods()  : mixed
My Account > Downloads template.
woocommerce_account_add_payment_method()  : mixed
My Account > Add payment method template.
woocommerce_account_edit_account()  : mixed
My Account > Edit account template.
wc_no_products_found()  : mixed
Handles the loop when no products were found/no product exist.
wc_get_email_order_items()  : string
Get HTML for the order items to be shown in emails.
wc_display_item_meta()  : string|void
Display item meta data.
wc_display_item_downloads()  : string|void
Display item download links.
woocommerce_photoswipe()  : mixed
Get the shop sidebar template.
wc_display_product_attributes()  : mixed
Outputs a list of product attributes for a product.
wc_get_stock_html()  : string
Get HTML to show product stock.
wc_get_rating_html()  : string
Get HTML for ratings.
wc_get_star_rating_html()  : string
Get HTML for star rating.
wc_get_price_html_from_text()  : string
Returns a 'from' prefix if you want to show where prices start at.
wc_logout_url()  : string
Get logout endpoint.
wc_empty_cart_message()  : mixed
Show notice if cart is empty.
wc_page_noindex()  : mixed
Disable search engines indexing core, dynamic, cart/checkout pages.
wc_page_no_robots()  : array<string|int, mixed>
Disable search engines indexing core, dynamic, cart/checkout pages.
wc_get_theme_slug_for_templates()  : string
Get a slug identifying the current theme.
wc_get_formatted_cart_item_data()  : string
Gets and formats a list of cart item data + variations for display on the frontend.
wc_get_cart_remove_url()  : string
Gets the url to remove an item from the cart.
wc_get_cart_undo_url()  : string
Gets the url to re-add an item into the cart.
woocommerce_output_all_notices()  : mixed
Outputs all queued notices on WC pages.
wc_products_rss_feed()  : mixed
Products RSS Feed.
woocommerce_reset_loop()  : mixed
Reset the loop's index and columns when we're done outputting a product loop.
woocommerce_product_reviews_tab()  : mixed
Output the reviews tab content.
wc_get_pay_buttons()  : mixed
Display pay buttons HTML.
wc_update_product_archive_title()  : string
Update the product archive title to the title of the shop page. Fallback to 'Shop' if the shop page doesn't exist.
wc_change_get_terms_defaults()  : array<string|int, mixed>
Change get terms defaults for attributes to order by the sorting setting, or default to menu_order for sortable taxonomies.
wc_change_pre_get_terms()  : mixed
Adds support to get_terms for menu_order argument.
wc_terms_clauses()  : array<string|int, mixed>
Adjust term query to handle custom sorting parameters.
wc_get_object_terms()  : array<string|int, mixed>
Helper to get cached object terms and filter by field using wp_list_pluck().
_wc_get_cached_product_terms()  : array<string|int, mixed>
Cached version of wp_get_post_terms().
wc_get_product_terms()  : array<string|int, mixed>
Wrapper used to get terms for a product.
_wc_get_product_terms_name_num_usort_callback()  : int
Sort by name (numeric).
_wc_get_product_terms_parent_usort_callback()  : int
Sort by parent.
wc_product_dropdown_categories()  : mixed
WooCommerce Dropdown categories.
wc_walk_category_dropdown_tree()  : mixed
Custom walker for Product Categories.
wc_taxonomy_metadata_migrate_data()  : mixed
Migrate data from WC term meta to WP term meta.
wc_reorder_terms()  : int
Move a term before the a given element of its hierarchy level.
wc_set_term_order()  : int
Set the sort order of a term.
_wc_term_recount()  : mixed
Function for recounting product terms, ignoring hidden products.
wc_recount_after_stock_change()  : mixed
Recount terms after the stock amount changes.
wc_change_term_counts()  : array<string|int, mixed>
Overrides the original term count for product categories and tags with the product count.
wc_get_term_product_ids()  : array<string|int, mixed>
Return products in a given term, and cache value.
wc_clear_term_product_ids()  : mixed
When a post is updated and terms recounted (called by _update_post_term_count), clear the ids.
wc_get_product_visibility_term_ids()  : array<string|int, int>
Get full list of product visibility term ids.
wc_recount_all_terms()  : void
Recounts all terms.
_wc_recount_terms_by_product()  : void
Recounts terms by product.
wc_update_200_file_paths()  : void
Update file paths for 2.0
wc_update_200_permalinks()  : void
Update permalinks for 2.0
wc_update_200_subcat_display()  : void
Update sub-category display options for 2.0
wc_update_200_taxrates()  : void
Update tax rates for 2.0
wc_update_200_line_items()  : void
Update order item line items for 2.0
wc_update_200_images()  : void
Update image settings for 2.0
wc_update_200_db_version()  : void
Update DB version for 2.0
wc_update_209_brazillian_state()  : void
Update Brazilian States for 2.0.9
wc_update_209_db_version()  : void
Update DB version for 2.0.9
wc_update_210_remove_pages()  : void
Remove pages for 2.1
wc_update_210_file_paths()  : void
Update file paths to support multiple files for 2.1
wc_update_210_db_version()  : void
Update DB version for 2.1
wc_update_220_shipping()  : void
Update shipping options for 2.2
wc_update_220_order_status()  : void
Update order statuses for 2.2
wc_update_220_variations()  : void
Update variations for 2.2
wc_update_220_attributes()  : void
Update attributes for 2.2
wc_update_220_db_version()  : void
Update DB version for 2.2
wc_update_230_options()  : void
Update options for 2.3
wc_update_230_db_version()  : void
Update DB version for 2.3
wc_update_240_options()  : void
Update calc discount options for 2.4
wc_update_240_shipping_methods()  : void
Update shipping methods for 2.4
wc_update_240_api_keys()  : void
Update API keys for 2.4
wc_update_240_webhooks()  : void
Update webhooks for 2.4
wc_update_240_refunds()  : void
Update refunds for 2.4
wc_update_240_db_version()  : void
Update DB version for 2.4
wc_update_241_variations()  : void
Update variations for 2.4.1
wc_update_241_db_version()  : void
Update DB version for 2.4.1
wc_update_250_currency()  : void
Update currency settings for 2.5
wc_update_250_db_version()  : void
Update DB version for 2.5
wc_update_260_options()  : void
Update ship to countries options for 2.6
wc_update_260_termmeta()  : void
Update term meta for 2.6
wc_update_260_zones()  : void
Update zones for 2.6
wc_update_260_zone_methods()  : void
Update zone methods for 2.6
wc_update_260_refunds()  : void
Update refunds for 2.6
wc_update_260_db_version()  : void
Update DB version for 2.6
wc_update_300_webhooks()  : void
Update webhooks for 3.0
wc_update_300_comment_type_index()  : mixed
Add an index to the field comment_type to improve the response time of the query used by WC_Comments::wp_count_comments() to get the number of comments by type.
wc_update_300_grouped_products()  : void
Update grouped products for 3.0
wc_update_300_settings()  : void
Update shipping tax classes for 3.0
wc_update_300_product_visibility()  : mixed
Convert meta values into term for product visibility.
wc_update_300_db_version()  : mixed
Update DB Version.
wc_update_310_downloadable_products()  : mixed
Add an index to the downloadable product permissions table to improve performance of update_user_by_order_id.
wc_update_310_old_comments()  : mixed
Find old order notes and ensure they have the correct type for exclusion.
wc_update_310_db_version()  : mixed
Update DB Version.
wc_update_312_shop_manager_capabilities()  : mixed
Update shop_manager capabilities.
wc_update_312_db_version()  : mixed
Update DB Version.
wc_update_320_mexican_states()  : mixed
Update state codes for Mexico.
wc_update_320_db_version()  : mixed
Update DB Version.
wc_update_330_image_options()  : mixed
Update image settings to use new aspect ratios and widths.
wc_update_330_webhooks()  : mixed
Migrate webhooks from post type to CRUD.
wc_update_330_set_default_product_cat()  : mixed
Assign default cat to all products with no cats.
wc_update_330_product_stock_status()  : mixed
Update product stock status to use the new onbackorder status.
wc_update_330_clear_transients()  : mixed
Clear addons page transients
wc_update_330_set_paypal_sandbox_credentials()  : mixed
Set PayPal's sandbox credentials.
wc_update_330_db_version()  : mixed
Update DB Version.
wc_update_340_states()  : mixed
Update state codes for Ireland and BD.
wc_update_340_state()  : bool
Update next state in the queue.
wc_update_340_last_active()  : mixed
Set last active prop for users.
wc_update_340_db_version()  : mixed
Update DB Version.
wc_update_343_cleanup_foreign_keys()  : void
Remove duplicate foreign keys
wc_update_343_db_version()  : void
Update DB version.
wc_update_344_recreate_roles()  : void
Recreate user roles so existing users will get the new capabilities.
wc_update_344_db_version()  : void
Update DB version.
wc_update_350_reviews_comment_type()  : mixed
Set the comment type to 'review' for product reviews that don't have a comment type.
wc_update_350_db_version()  : mixed
Update DB Version.
wc_update_352_drop_download_log_fk()  : void
Drop the fk_wc_download_log_permission_id FK as we use a new one with the table and blog prefix for MS compatibility.
wc_update_354_modify_shop_manager_caps()  : mixed
Remove edit_user capabilities from shop managers and use "translated" capabilities instead.
wc_update_354_db_version()  : mixed
Update DB Version.
wc_update_360_product_lookup_tables()  : mixed
Update product lookup tables in bulk.
wc_update_360_term_meta()  : mixed
Renames ordering meta to be consistent across taxonomies.
wc_update_360_downloadable_product_permissions_index()  : void
Add new user_order_remaining_expires to speed up user download permission fetching.
wc_update_360_db_version()  : mixed
Update DB Version.
wc_update_370_tax_rate_classes()  : void
Put tax classes into a DB table.
wc_update_370_mro_std_currency()  : void
Update currency settings for 3.7.0
wc_update_370_db_version()  : mixed
Update DB Version.
wc_update_390_move_maxmind_database()  : mixed
We've moved the MaxMind database to a new location, as per the TOS' requirement that the database not be publicly accessible.
wc_update_390_change_geolocation_database_update_cron()  : mixed
So that we can best meet MaxMind's TOS, the geolocation database update cron should run once per 15 days.
wc_update_390_db_version()  : mixed
Update DB version.
wc_update_400_increase_size_of_column()  : mixed
Increase column size
wc_update_400_reset_action_scheduler_migration_status()  : mixed
Reset ActionScheduler migration status. Needs AS >= 3.0 shipped with WC >= 4.0.
wc_update_400_db_version()  : mixed
Update DB version.
wc_update_440_insert_attribute_terms_for_variable_products()  : bool
Register attributes as terms for variable products, in increments of 100 products.
wc_update_440_db_version()  : mixed
Update DB version.
wc_update_450_db_version()  : mixed
Update DB version to 4.5.0.
wc_update_450_sanitize_coupons_code()  : bool
Sanitize all coupons code.
wc_update_500_fix_product_review_count()  : mixed
Fixes product review count that might have been incorrect.
wc_update_500_db_version()  : mixed
Update DB version to 5.0.0.
wc_update_560_create_refund_returns_page()  : mixed
Creates the refund and returns policy page.
wc_update_560_db_version()  : mixed
Update DB version to 5.6.0.
wc_update_600_migrate_rate_limit_options()  : mixed
Migrate rate limit options to the new table.
wc_update_600_db_version()  : mixed
Update DB version to 6.0.0.
wc_update_630_create_product_attributes_lookup_table()  : false
Create the product attributes lookup table and initiate its filling, unless the table had been already created manually (via the tools page).
wc_update_630_db_version()  : mixed
Update DB version to 6.3.0.
wc_update_640_add_primary_key_to_product_attributes_lookup_table()  : bool
Create the primary key for the product attributes lookup table if it doesn't exist already.
wc_update_640_db_version()  : mixed
Update DB version to 6.4.0.
wc_update_650_approved_download_directories()  : mixed
Add the standard WooCommerce upload directories to the Approved Product Download Directories list and start populating it based on existing product download URLs, but do not enable the feature (for existing installations, a site admin should review and make a conscious decision to enable).
wc_update_651_approved_download_directories()  : mixed
In some cases, the approved download directories table may not have been successfully created during the update to 6.5.0. If this was the case we will need to re-initialize the feature.
wc_update_670_purge_comments_count_cache()  : mixed
Purges the comments count cache after 6.7.0 split reviews from the comments page.
wc_update_700_remove_download_log_fk()  : void
Remove unnecessary foreign keys.
wc_update_700_remove_recommended_marketing_plugins_transient()  : mixed
Remove the transient data for recommended marketing extensions.
wc_update_721_adjust_new_zealand_states()  : mixed
Update the New Zealand state codes in the database after they were updated in code to the CLDR standard.
wc_update_721_adjust_ukraine_states()  : mixed
Update the Ukraine state codes in the database after they were updated in code to the CLDR standard.
wc_update_722_adjust_new_zealand_states()  : mixed
Update the New Zealand state codes in the database after they were updated in code to the CLDR standard.
wc_update_722_adjust_ukraine_states()  : mixed
Update the Ukraine state codes in the database after they were updated in code to the CLDR standard.
wc_update_750_add_columns_to_order_stats_table()  : mixed
Add new columns date_paid and date_completed to wp_wc_order_stats table in order to provide the option of using the dates in the reports
wc_update_750_disable_new_product_management_experience()  : void
Disable the experimental product management experience.
wc_update_770_remove_multichannel_marketing_feature_options()  : mixed
Remove the multichannel marketing feature flag and options. This feature is now enabled by default.
wc_update_810_migrate_transactional_metadata_for_hpos()  : bool
Migrate transaction data which was being incorrectly stored in the postmeta table to HPOS tables.
wc_update_860_remove_recommended_marketing_plugins_transient()  : mixed
Remove the transient data for recommended marketing extensions.
wc_update_870_prevent_listing_of_transient_files_directory()  : mixed
Create an .htaccess file and an empty index.html file to prevent listing of the default transient files directory, if the directory exists.
wc_update_890_update_connect_to_woocommerce_note()  : mixed
If it exists, remove and recreate the inbox note that asks users to connect to `Woo.com` so that the domain name is changed to the updated `WooCommerce.com`.
wc_update_890_update_paypal_standard_load_eligibility()  : mixed
Disables the PayPal Standard gateway for stores that aren't using it.
wc_update_891_create_plugin_autoinstall_history_option()  : mixed
Create the woocommerce_history_of_autoinstalled_plugins option if it doesn't exist as a copy of woocommerce_autoinstalled_plugins if it exists.
wc_update_910_add_launch_your_store_tour_option()  : mixed
Add woocommerce_show_lys_tour.
wc_update_910_remove_obsolete_user_meta()  : void
Remove user meta associated with the keys '_last_order', '_order_count' and '_money_spent'.
wc_disable_admin_bar()  : bool
Prevent any user who cannot 'edit_posts' (subscribers, customers etc) from seeing the admin bar.
wc_create_new_customer()  : int|WP_Error
Create a new customer.
wc_create_new_customer_username()  : string
Create a unique username for a new customer.
wc_set_customer_auth_cookie()  : mixed
Login a customer (set auth cookie and set global user object).
wc_update_new_customer_past_orders()  : int
Get past orders (by email) and update them.
wc_paying_customer()  : mixed
Order payment completed - This is a paying customer.
wc_customer_bought_product()  : bool
Checks if a user (by email or ID or both) has bought an item.
wc_current_user_has_role()  : bool
Checks if the current user has a role.
wc_user_has_role()  : bool
Checks if a user has a role.
wc_customer_has_capability()  : array<string|int, mixed>
Checks if a user has a certain capability.
wc_shop_manager_has_capability()  : array<string|int, bool>
Safe way of allowing shop managers restricted capabilities that will remove access to the capabilities if WooCommerce is deactivated.
wc_modify_editable_roles()  : array<string|int, mixed>
Modify the list of editable roles to prevent non-admin adding admin users.
wc_modify_map_meta_cap()  : array<string|int, mixed>
Modify capabilities to prevent non-admin users editing admin users.
wc_get_customer_download_permissions()  : array<string|int, mixed>
Get customer download permissions from the database.
wc_get_customer_available_downloads()  : array<string|int, mixed>
Get customer available downloads.
wc_get_customer_total_spent()  : string
Get total spent by customer.
wc_get_customer_order_count()  : int
Get total orders by customer.
wc_reset_order_customer_id_on_deleted_user()  : mixed
Reset _customer_user on orders when a user is deleted.
wc_review_is_from_verified_owner()  : bool
Get review verification status.
wc_disable_author_archives_for_customers()  : mixed
Disable author archives for customers.
wc_update_profile_last_update_time()  : mixed
Hooks into the `profile_update` hook to set the user last updated timestamp.
wc_meta_update_last_update_time()  : mixed
Hooks into the update user meta function to set the user last updated timestamp.
wc_set_user_last_update_time()  : mixed
Sets a user's "last update" time to the current timestamp.
wc_get_customer_saved_methods_list()  : array<string|int, mixed>
Get customer saved payment methods list.
wc_get_customer_last_order()  : WC_Order|bool
Get info about customer's last order.
wc_user_search_columns()  : array<string|int, mixed>
Add support for searching by display_name.
wc_delete_user_data()  : mixed
When a user is deleted in WordPress, delete corresponding WooCommerce data.
wc_maybe_store_user_agent()  : mixed
Store user agents. Used for tracker.
wc_user_logged_in()  : mixed
Update logic triggered on login.
wc_current_user_is_active()  : mixed
Update when the user was last active.
wc_update_user_last_active()  : mixed
Set the user last active timestamp to now.
wc_translate_user_roles()  : string
Translate WC roles using the woocommerce textdomain.
wc_webhook_execute_queue()  : mixed
Process the web hooks at the end of the request.
wc_webhook_process_delivery()  : mixed
Process webhook delivery.
wc_deliver_webhook_async()  : mixed
Wrapper function to execute the `woocommerce_deliver_webhook_async` cron.
wc_is_webhook_valid_topic()  : bool
Check if the given topic is a valid webhook topic, a topic is valid if:
wc_is_webhook_valid_status()  : bool
Check if given status is a valid webhook status.
wc_get_webhook_statuses()  : array<string|int, mixed>
Get Webhook statuses.
wc_load_webhooks()  : bool
Load webhooks.
wc_get_webhook()  : WC_Webhook|null
Get webhook.
wc_get_webhook_rest_api_versions()  : array<string|int, mixed>
Get webhoook REST API versions.
wc_register_widgets()  : mixed
Register Widgets.

Functions

wc_lostpassword_url()

Returns the url to the lost password endpoint url.

wc_lostpassword_url([string $default_url = '' ]) : string
Parameters
$default_url : string = ''

Default lost password URL.

wc_edit_address_i18n()

Get the edit address slug translation.

wc_edit_address_i18n(string $id[, bool $flip = false ]) : string
Parameters
$id : string

Address ID.

$flip : bool = false

Flip the array to make it possible to retrieve the values ​​from both sides.

wc_get_account_menu_items()

Get My Account menu items.

wc_get_account_menu_items() : array<string|int, mixed>
Tags
since
2.6.0

wc_get_account_menu_item_classes()

Get account menu item classes.

wc_get_account_menu_item_classes(string $endpoint) : string
Parameters
$endpoint : string

Endpoint.

Tags
since
2.6.0

wc_get_account_endpoint_url()

Get account endpoint URL.

wc_get_account_endpoint_url(string $endpoint) : string
Parameters
$endpoint : string

Endpoint.

Tags
since
2.6.0

wc_get_account_orders_columns()

Get My Account > Orders columns.

wc_get_account_orders_columns() : array<string|int, mixed>
Tags
since
2.6.0

wc_get_account_downloads_columns()

Get My Account > Downloads columns.

wc_get_account_downloads_columns() : array<string|int, mixed>
Tags
since
2.6.0

wc_get_account_payment_methods_columns()

Get My Account > Payment methods columns.

wc_get_account_payment_methods_columns() : array<string|int, mixed>
Tags
since
2.6.0

wc_get_account_payment_methods_types()

Get My Account > Payment methods types

wc_get_account_payment_methods_types() : array<string|int, mixed>
Tags
since
2.6.0

wc_get_account_orders_actions()

Get account orders actions.

wc_get_account_orders_actions(int|WC_Order $order) : array<string|int, mixed>
Parameters
$order : int|WC_Order

Order instance or ID.

Tags
since
3.2.0

wc_get_account_formatted_address()

Get account formatted address.

wc_get_account_formatted_address([string $address_type = 'billing' ], int $customer_id) : string
Parameters
$address_type : string = 'billing'

Type of address; 'billing' or 'shipping'.

$customer_id : int

Customer ID. Defaults to 0.

Tags
since
3.2.0

wc_get_account_saved_payment_methods_list()

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>
Parameters
$list : array<string|int, mixed>

List of payment methods passed from wc_get_customer_saved_methods_list().

$customer_id : int

The customer to fetch payment methods for.

Tags
since
2.6

wc_get_account_saved_payment_methods_list_item_cc()

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>
Parameters
$item : array<string|int, mixed>

Individual list item from woocommerce_saved_payment_methods_list.

$payment_token : WC_Payment_Token

The payment token associated with this method entry.

Tags
since
2.6

wc_get_account_saved_payment_methods_list_item_echeck()

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>
Parameters
$item : array<string|int, mixed>

Individual list item from woocommerce_saved_payment_methods_list.

$payment_token : WC_Payment_Token

The payment token associated with this method entry.

Tags
since
2.6

wc_get_text_attributes()

Gets text attributes from a string.

wc_get_text_attributes(string $raw_attributes) : array<string|int, mixed>
Parameters
$raw_attributes : string

Raw attributes.

Tags
since
2.4

wc_get_text_attributes_filter_callback()

See if an attribute is actually valid.

wc_get_text_attributes_filter_callback(string $value) : bool
Parameters
$value : string

Value.

Tags
since
3.0.0

wc_implode_text_attributes()

Implode an array of attributes using WC_DELIMITER.

wc_implode_text_attributes(array<string|int, mixed> $attributes) : string
Parameters
$attributes : array<string|int, mixed>

Attributes list.

Tags
since
3.0.0

wc_get_attribute_taxonomy_ids()

Get (cached) attribute taxonomy ID and name pairs.

wc_get_attribute_taxonomy_ids() : array<string|int, mixed>
Tags
since
3.6.0

wc_get_attribute_taxonomy_labels()

Get (cached) attribute taxonomy label and name pairs.

wc_get_attribute_taxonomy_labels() : array<string|int, mixed>
Tags
since
3.6.0

wc_attribute_taxonomy_name()

Get a product attribute name.

wc_attribute_taxonomy_name(string $attribute_name) : string
Parameters
$attribute_name : string

Attribute name.

wc_variation_attribute_name()

Get the attribute name used when storing values in post meta.

wc_variation_attribute_name(string $attribute_name) : string
Parameters
$attribute_name : string

Attribute name.

Tags
since
2.6.0

wc_attribute_taxonomy_name_by_id()

Get a product attribute name by ID.

wc_attribute_taxonomy_name_by_id(int $attribute_id) : string
Parameters
$attribute_id : int

Attribute ID.

Tags
since
2.4.0

wc_attribute_taxonomy_id_by_name()

Get a product attribute ID by name.

wc_attribute_taxonomy_id_by_name(string $name) : int
Parameters
$name : string

Attribute name.

Tags
since
2.6.0

wc_attribute_orderby()

Get a product attributes orderby setting.

wc_attribute_orderby(string $name) : string
Parameters
$name : string

Attribute name.

wc_get_attribute_taxonomy_names()

Get an array of product attribute taxonomies.

wc_get_attribute_taxonomy_names() : array<string|int, mixed>

wc_get_attribute_type_label()

Get attribute type label.

wc_get_attribute_type_label(string $type) : string
Parameters
$type : string

Attribute type slug.

Tags
since
3.0.0

wc_check_if_attribute_name_is_reserved()

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.

Parameters
$attribute_name : string

Attribute name.

Tags
since
2.4.0

wc_is_attribute_in_product_name()

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
Parameters
$attribute : string

Attribute value to check for.

$name : string

Product name to check in.

Tags
since
3.0.2

wc_array_filter_default_attributes()

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
Parameters
$attribute : mixed

Attribute being considered for exclusion from parent array.

Tags
since
3.1.0

wc_get_attribute()

Get attribute data by ID.

wc_get_attribute(int $id) : stdClass|null
Parameters
$id : int

Attribute ID.

Tags
since
3.2.0

wc_create_attribute()

Create attribute.

wc_create_attribute(array<string|int, mixed> $args) : int|WP_Error
Parameters
$args : array<string|int, mixed>

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.

}

Tags
since
3.2.0

wc_update_attribute()

Update an attribute.

wc_update_attribute(int $id, array<string|int, mixed> $args) : int|WP_Error

For available args see wc_create_attribute().

Parameters
$id : int

Attribute ID.

$args : array<string|int, mixed>

Attribute arguments.

Tags
since
3.2.0

wc_delete_attribute()

Delete attribute by ID.

wc_delete_attribute(int $id) : bool
Parameters
$id : int

Attribute ID.

Tags
since
3.2.0

wc_attribute_taxonomy_slug()

Get an unprefixed product attribute name.

wc_attribute_taxonomy_slug(string $attribute_name) : string
Parameters
$attribute_name : string

Attribute name.

Tags
since
3.6.0

wc_protected_product_add_to_cart()

Prevent password protected products being added to the cart.

wc_protected_product_add_to_cart(bool $passed, int $product_id) : bool
Parameters
$passed : bool

Validation.

$product_id : int

Product ID.

wc_load_persistent_cart()

Load the persistent cart.

wc_load_persistent_cart(string $user_login, WP_User $user) : mixed
Parameters
$user_login : string

User login.

$user : WP_User

User data.

Tags
deprecated
2.3

wc_get_raw_referer()

Retrieves unvalidated referer from '_wp_http_referer' or HTTP referer.

wc_get_raw_referer() : string|false

Do not use for redirects, use {@see} instead.

Tags
since
2.6.1

wc_add_to_cart_message()

Add to cart messages.

wc_add_to_cart_message(int|array<string|int, mixed> $products[, bool $show_qty = false ][, bool $return = false ]) : mixed
Parameters
$products : int|array<string|int, mixed>

Product ID list or single product ID.

$show_qty : bool = false

Should quantities be shown? Added in 2.6.0.

$return : bool = false

Return message rather than add it.

wc_format_list_of_items()

Comma separate a list of item names, and replace final comma with 'and'.

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

Cart items.

wc_cart_totals_coupon_label()

Get a coupon label.

wc_cart_totals_coupon_label(string|WC_Coupon $coupon[, bool $echo = true ]) : string
Parameters
$coupon : string|WC_Coupon

Coupon data or code.

$echo : bool = true

Echo or return.

wc_cart_totals_order_total_html()

Get order total html including inc tax if needed.

wc_cart_totals_order_total_html() : mixed

wc_cart_totals_fee_html()

Get the fee value.

wc_cart_totals_fee_html(object $fee) : mixed
Parameters
$fee : object

Fee data.

wc_cart_round_discount()

Round discount.

wc_cart_round_discount(float $value, int $precision) : float
Parameters
$value : float

Amount to round.

$precision : int

DP to round.

wc_get_chosen_shipping_method_ids()

Gets chosen shipping method IDs from chosen_shipping_methods session, without instance IDs.

wc_get_chosen_shipping_method_ids() : array<string|int, string>
Tags
since
2.6.2

wc_get_chosen_shipping_method_for_package()

Get chosen method for package from session.

wc_get_chosen_shipping_method_for_package(int $key, array<string|int, mixed> $package) : string|bool
Parameters
$key : int

Key of package.

$package : array<string|int, mixed>

Package data array.

Tags
since
3.2.0

wc_get_default_shipping_method_for_package()

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
Parameters
$key : int

Key of package.

$package : array<string|int, mixed>

Package data array.

$chosen_method : string

Chosen shipping method. e.g. flat_rate:1.

Tags
since
3.2.0

wc_shipping_methods_have_changed()

See if the methods have changed since the last request.

wc_shipping_methods_have_changed(int $key, array<string|int, mixed> $package) : bool
Parameters
$key : int

Key of package.

$package : array<string|int, mixed>

Package data array.

Tags
since
3.2.0

wc_get_cart_item_data_hash()

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.

Parameters
$product : WC_Product

Product object.

is_woocommerce()

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_product_category()

Is_product_category - Returns true when viewing a product category.

is_product_category([string $term = '' ]) : bool
Parameters
$term : string = ''

(default: '') The term slug your checking for. Leave blank to return true on any.

is_product_tag()

Is_product_tag - Returns true when viewing a product tag.

is_product_tag([string $term = '' ]) : bool
Parameters
$term : string = ''

(default: '') The term slug your checking for. Leave blank to return true on any.

is_checkout()

Is_checkout - Returns true when viewing the checkout page, or when processing AJAX requests for updating or processing the checkout.

is_checkout() : bool

is_wc_endpoint_url()

Is_wc_endpoint_url - Check if an endpoint is showing.

is_wc_endpoint_url([string|false $endpoint = false ]) : bool
Parameters
$endpoint : string|false = false

Whether endpoint.

is_edit_account_page()

Check for edit account page.

is_edit_account_page() : bool

Returns true when viewing the edit account page.

Tags
since
2.5.1

is_add_payment_method_page()

Is_add_payment_method_page - Returns true when viewing the add payment method page.

is_add_payment_method_page() : bool

is_ajax()

Is_ajax - Returns true when the page is loaded via ajax.

is_ajax() : bool
Tags
see
wp_doing_ajax()

for an equivalent function provided by WordPress since 4.7.0

taxonomy_is_product_attribute()

Returns true when the passed taxonomy name is a product attribute.

taxonomy_is_product_attribute(string $name) : bool
Parameters
$name : string

of the attribute.

Tags
uses

$wc_product_attributes global which stores taxonomy names upon registration

meta_is_product_attribute()

Returns true when the passed meta name is a product attribute.

meta_is_product_attribute(string $name, string $value, int $product_id) : bool
Parameters
$name : string

of the attribute.

$value : string

of the attribute.

$product_id : int

to check for attribute.

wc_is_valid_url()

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.

Parameters
$url : string

to check.

wc_site_is_https()

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
Tags
since
2.4.13

wc_checkout_is_https()

Check if the checkout is configured for https. Look at options, WP HTTPS plugin, or the permalink itself.

wc_checkout_is_https() : bool
Tags
since
2.5.0

wc_post_content_has_shortcode()

Checks whether the content passed contains a specific short code.

wc_post_content_has_shortcode([string $tag = '' ]) : bool
Parameters
$tag : string = ''

Shortcode tag to check.

wc_is_file_valid_csv()

Check if a CSV file is valid.

wc_is_file_valid_csv(string $file[, bool $check_path = true ]) : bool
Parameters
$file : string

File name.

$check_path : bool = true

If should check for the path.

Tags
since
3.6.5

wc_current_theme_supports_woocommerce_or_fse()

Check if the current theme has WooCommerce support or is a FSE theme.

wc_current_theme_supports_woocommerce_or_fse() : bool
Tags
since
6.0.0

wc_wp_theme_get_element_class_name()

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.

Parameters
$element : string

The name of the element.

Tags
since
7.0.1

wc_block_theme_has_styles_for_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.

Parameters
$element : string

The name of the element.

Tags
since
7.4.0

wc_maybe_define_constant()

Define a constant if it is not already defined.

wc_maybe_define_constant(string $name, mixed $value) : mixed
Parameters
$name : string

Constant name.

$value : mixed

Value.

Tags
since
3.0.0

wc_create_order()

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.

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

Order arguments.

wc_update_order()

Update an order. Uses wc_create_order.

wc_update_order(array<string|int, mixed> $args) : WC_Order|WP_Error
Parameters
$args : array<string|int, mixed>

Order arguments.

wc_tokenize_path()

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
Parameters
$path : string

The absolute path to tokenize.

$path_tokens : array<string|int, mixed>

An array keyed with the token, containing paths that should be replaced.

Tags
since
4.3.0

wc_untokenize_path()

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
Parameters
$path : string

The absolute path to expand.

$path_tokens : array<string|int, mixed>

An array keyed with the token, containing paths that should be expanded.

Tags
since
4.3.0

wc_get_path_define_tokens()

Fetches an array containing all of the configurable path constants to be used in tokenization.

wc_get_path_define_tokens() : array<string|int, mixed>

wc_get_template_part()

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.

Parameters
$slug : mixed

Template slug.

$name : string = ''

Template name (default: '').

wc_get_template()

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
Parameters
$template_name : string

Template name.

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

Arguments. (default: array).

$template_path : string = ''

Template path. (default: '').

$default_path : string = ''

Default path. (default: '').

wc_get_template_html()

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
Parameters
$template_name : string

Template name.

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

Arguments. (default: array).

$template_path : string = ''

Template path. (default: '').

$default_path : string = ''

Default path. (default: '').

Tags
see
wc_get_template
since
2.5.0

wc_locate_template()

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

Parameters
$template_name : string

Template name.

$template_path : string = ''

Template path. (default: '').

$default_path : string = ''

Default path. (default: '').

wc_set_template_cache()

Add a template to the template cache.

wc_set_template_cache(string $cache_key, string $template) : mixed
Parameters
$cache_key : string

Object cache key.

$template : string

Located template.

Tags
since
4.3.0

get_woocommerce_currencies()

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_woocommerce_currency_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)

Tags
since
4.1.0

get_woocommerce_currency_symbol()

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)

Parameters
$currency : string = ''

Currency. (default: '').

wc_mail()

Send HTML emails from WooCommerce.

wc_mail(mixed $to, mixed $subject, mixed $message[, string $headers = "Content-Type: text/html " ][, string $attachments = '' ]) : bool
Parameters
$to : mixed

Receiver.

$subject : mixed

Subject.

$message : mixed

Message.

$headers : string = "Content-Type: text/html "

Headers. (default: "Content-Type: text/html\r\n").

$attachments : string = ''

Attachments. (default: "").

wc_get_theme_support()

Return "theme support" values from the current theme, if set.

wc_get_theme_support([string $prop = '' ][, mixed $default = null ]) : mixed
Parameters
$prop : string = ''

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.

$default : mixed = null

Optional value to return if the theme does not declare support for a prop.

Tags
since
3.3.0

wc_get_image_size()

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.

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

Name of the image size to get, or an array of dimensions.

wc_enqueue_js()

Queue some JavaScript code to be output in the footer.

wc_enqueue_js(string $code) : mixed
Parameters
$code : string

Code.

wc_setcookie()

Set a cookie - wrapper for setcookie using WP constants.

wc_setcookie(string $name, string $value, int $expire[, bool $secure = false ][, bool $httponly = false ]) : mixed
Parameters
$name : string

Name of the cookie being set.

$value : string

Value of the cookie.

$expire : int

Expiry of the cookie.

$secure : bool = false

Whether the cookie should be served only over https.

$httponly : bool = false

Whether the cookie is only accessible over HTTP, not scripting languages like JavaScript. @since 3.6.0.

get_woocommerce_api_url()

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/

Parameters
$path : string

an endpoint to include in the URL.

Tags
deprecated
9.0.0

The Legacy REST API has been removed from WooCommerce core.

since
2.1

wc_get_page_children()

Recursively get page children.

wc_get_page_children(int $page_id) : array<string|int, int>
Parameters
$page_id : int

Page ID.

flush_rewrite_rules_on_shop_page_save()

Flushes rewrite rules when the shop page (or it's children) gets saved.

flush_rewrite_rules_on_shop_page_save() : mixed

wc_fix_rewrite_rules()

Various rewrite rule fixes.

wc_fix_rewrite_rules(array<string|int, mixed> $rules) : array<string|int, mixed>
Parameters
$rules : array<string|int, mixed>

Rules.

Tags
since
2.2

Prevent product attachment links from breaking when using complex rewrite structures.

wc_fix_product_attachment_link(string $link, int $post_id) : string
Parameters
$link : string

Link.

$post_id : int

Post ID.

wc_ms_protect_download_rewite_rules()

Protect downloads from ms-files.php in multisite.

wc_ms_protect_download_rewite_rules(string $rewrite) : string
Parameters
$rewrite : string

rewrite rules.

wc_format_country_state_string()

Formats a string in the format COUNTRY:STATE into an array.

wc_format_country_state_string(string $country_string) : array<string|int, mixed>
Parameters
$country_string : string

Country string.

Tags
since
2.3.0

wc_get_base_location()

Get the store's base location.

wc_get_base_location() : array<string|int, mixed>
Tags
since
2.3.0

wc_get_customer_default_location()

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.

Tags
since
2.3.0

wc_api_hash()

WC API - Hash.

wc_api_hash(string $data) : string
Parameters
$data : string

Message to be hashed.

Tags
since
2.4.0

wc_array_cartesian()

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>
Parameters
$input : array<string|int, mixed>

Input.

Tags
since
2.5.0

wc_transaction_query()

Run a MySQL transaction query, if supported.

wc_transaction_query([string $type = 'start' ][, bool $force = false ]) : mixed
Parameters
$type : string = 'start'

Types: start (default), commit, rollback.

$force : bool = false

use of transactions.

Tags
since
2.5.0

woocommerce_register_shipping_method()

Register a shipping method.

woocommerce_register_shipping_method(string|object $shipping_method) : mixed
Parameters
$shipping_method : string|object

class name (string) or a class object.

Tags
since
1.5.7

wc_get_shipping_zone()

Get the shipping zone matching a given package from the cart.

wc_get_shipping_zone(array<string|int, mixed> $package) : WC_Shipping_Zone
Parameters
$package : array<string|int, mixed>

Shipping package.

Tags
since
2.6.0
uses
WC_Shipping_Zones::get_zone_matching_package

wc_get_credit_card_type_label()

Get a nice name for credit card providers.

wc_get_credit_card_type_label(string $type) : string
Parameters
$type : string

Provider Slug/Type.

Tags
since
2.6.0

Outputs a "back" link so admin screens can easily jump back a page.

wc_back_link(string $label, string $url) : mixed
Parameters
$label : string

Title of the page to return to.

$url : string

URL of the page to return to.

wc_help_tip()

Display a WooCommerce help tip.

wc_help_tip(string $tip[, bool $allow_html = false ]) : string
Parameters
$tip : string

Help tip text.

$allow_html : bool = false

Allow sanitized HTML if true or escape.

Tags
since
2.5.0

wc_get_wildcard_postcodes()

Return a list of potential postcodes for wildcard searching.

wc_get_wildcard_postcodes(string $postcode[, string $country = '' ]) : array<string|int, string>
Parameters
$postcode : string

Postcode.

$country : string = ''

Country to format postcode for matching.

Tags
since
2.6.0

wc_postcode_location_matcher()

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>
Parameters
$postcode : string

Postcode you want to match against stored postcodes.

$objects : array<string|int, mixed>

Array of postcode objects from Database.

$object_id_key : string

DB column name for the ID.

$object_compare_key : string

DB column name for the value.

$country : string = ''

Country from which this postcode belongs. Allows for formatting.

Tags
since
2.6.0

wc_get_shipping_method_count()

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
Parameters
$include_legacy : bool = false

Count legacy shipping methods too.

$enabled_only : bool = false

Whether non-legacy shipping methods should be restricted to enabled ones. It doesn't affect legacy shipping methods. @since 4.3.0.

Tags
since
2.6.0

wc_set_time_limit()

Wrapper for set_time_limit to see if it is enabled.

wc_set_time_limit(int $limit) : mixed
Parameters
$limit : int

Time limit.

Tags
since
2.6.0

wc_nocache_headers()

Wrapper for nocache_headers which also disables page caching.

wc_nocache_headers() : mixed
Tags
since
3.2.4

wc_product_attribute_uasort_comparison()

Used to sort products attributes with uasort.

wc_product_attribute_uasort_comparison(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
$a : array<string|int, mixed>

First attribute to compare.

$b : array<string|int, mixed>

Second attribute to compare.

Tags
since
2.6.0

wc_shipping_zone_method_order_uasort_comparison()

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
Parameters
$a : array<string|int, mixed>

First shipping zone method to compare.

$b : array<string|int, mixed>

Second shipping zone method to compare.

Tags
since
3.0.0

wc_checkout_fields_uasort_comparison()

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
Parameters
$a : array<string|int, mixed>

First field to compare.

$b : array<string|int, mixed>

Second field to compare.

Tags
since
3.5.1

wc_uasort_comparison()

User to sort two values with ausort.

wc_uasort_comparison(int $a, int $b) : int
Parameters
$a : int

First value to compare.

$b : int

Second value to compare.

Tags
since
3.5.1

wc_ascii_uasort_comparison()

Sort values based on ascii, usefull for special chars in strings.

wc_ascii_uasort_comparison(string $a, string $b) : int
Parameters
$a : string

First value.

$b : string

Second value.

wc_asort_by_locale()

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.

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

List of values to sort.

$locale : string = ''

Locale.

Tags
since
4.6.0

wc_get_tax_rounding_mode()

Get rounding mode for internal tax calculations.

wc_get_tax_rounding_mode() : int
Tags
since
3.2.4

wc_get_rounding_precision()

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.

Tags
since
2.6.3

wc_add_number_precision()

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.

Parameters
$value : float|null

Number to add precision to.

$round : bool = true

If the result should be rounded.

Tags
since
3.2.0

wc_remove_number_precision()

Remove precision from a number and return a float.

wc_remove_number_precision(float $value) : float
Parameters
$value : float

Number to add precision to.

Tags
since
3.2.0

wc_add_number_precision_deep()

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>
Parameters
$value : array<string|int, mixed>

Number to add precision to.

$round : bool = true

Should we round after adding precision?.

Tags
since
3.2.0

wc_remove_number_precision_deep()

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>
Parameters
$value : array<string|int, mixed>

Number to add precision to.

Tags
since
3.2.0

wc_get_logger()

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.

wc_print_r()

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.

Parameters
$expression : mixed

The expression to be printed.

$return : bool = false

Optional. Default false. Set to true to return the human-readable string.

Tags
since
3.0

wc_list_pluck()

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>
Parameters
$list : array<string|int, mixed>

List of objects or arrays.

$callback_or_field : int|string

Callback method from the object to place instead of the entire object.

$index_key : int|string = null

Optional. Field from the object to use as keys for the new array. Default null.

Tags
since
3.0.0

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.

Tags
since
3.0.0

wc_switch_to_site_locale()

Switch WooCommerce to site language.

wc_switch_to_site_locale() : mixed
Tags
since
3.1.0

wc_make_phone_clickable()

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

Parameters
$phone : string

Content to convert phone number.

Tags
since
3.1.0

wc_get_post_data_by_key()

Get an item of post data if set, otherwise return a default value.

wc_get_post_data_by_key(string $key[, string $default = '' ]) : mixed
Parameters
$key : string

Meta key.

$default : string = ''

Default value.

Tags
since
3.0.9

wc_get_var()

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
Parameters
$var : mixed

Variable.

$default : string = null

Default value.

Tags
since
3.2.0

wc_enable_wc_plugin_headers()

Read in WooCommerce headers when reading plugin headers.

wc_enable_wc_plugin_headers(array<string|int, mixed> $headers) : array<string|int, mixed>
Parameters
$headers : array<string|int, mixed>

Headers.

Tags
since
3.2.0

wc_prevent_dangerous_auto_updates()

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
Parameters
$should_update : bool

If should update.

$plugin : object

Plugin data.

Tags
since
3.2.0

wc_delete_expired_transients()

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.

Tags
since
3.2.0

wc_get_relative_url()

Make a URL relative, if possible.

wc_get_relative_url(string $url) : string
Parameters
$url : string

URL to make relative.

Tags
since
3.2.0

wc_is_external_resource()

See if a resource is remote.

wc_is_external_resource(string $url) : bool
Parameters
$url : string

URL to check.

Tags
since
3.2.0

wc_is_active_theme()

See if theme/s is activate or not.

wc_is_active_theme(string|array<string|int, mixed> $theme) : bool
Parameters
$theme : string|array<string|int, mixed>

Theme name or array of theme names to check.

Tags
since
3.3.0

wc_cleanup_session_data()

Cleans up session data - cron callback.

wc_cleanup_session_data() : mixed
Tags
since
3.3.0

wc_decimal_to_fraction()

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/

Parameters
$decimal : float

the decimal number.

wc_round_discount()

Round discount.

wc_round_discount(float $value, int $precision) : float
Parameters
$value : float

Amount to round.

$precision : int

DP to round.

wc_selected()

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
Parameters
$value : string|int

Value to find within options.

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

Options to go through when looking for value.

wc_get_server_database_version()

Retrieves the MySQL server version. Based on $wpdb.

wc_get_server_database_version() : array<string|int, mixed>
Tags
since
3.4.1

wc_is_running_from_async_action_scheduler()

Test whether the context of execution comes from async action scheduler.

wc_is_running_from_async_action_scheduler() : bool
Tags
since
4.0.0

wc_cache_get_multiple()

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
Parameters
$keys : array<string|int, mixed>

Array of keys to get from group.

$group : string = ''

Optional. Where the cache contents are grouped. Default empty.

$force : bool = false

Optional. Whether to force an update of the local cache from the persistent cache. Default false.

wc_get_coupon_type()

Get a coupon type's name.

wc_get_coupon_type([string $type = '' ]) : string
Parameters
$type : string = ''

Coupon type.

wc_get_product_coupon_types()

Coupon types that apply to individual products. Controls which validation rules will apply.

wc_get_product_coupon_types() : array<string|int, mixed>
Tags
since
2.5.0

wc_get_cart_coupon_types()

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>
Tags
since
2.5.0

wc_get_coupon_code_by_id()

Get coupon code by ID.

wc_get_coupon_code_by_id(int $id) : string
Parameters
$id : int

Coupon ID.

Tags
since
3.0.0

wc_get_coupon_id_by_code()

Get coupon ID by code.

wc_get_coupon_id_by_code(string $code, int $exclude) : int
Parameters
$code : string

Coupon code.

$exclude : int

Used to exclude an ID from the check if you're checking existence.

Tags
since
3.0.0

wc_do_deprecated_action()

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
Parameters
$tag : string

The name of the action hook.

$args : array<string|int, mixed>

Array of additional function arguments to be passed to do_action().

$version : string

The version of WooCommerce that deprecated the hook.

$replacement : string = null

The hook that should have been used.

$message : string = null

A message regarding the change.

Tags
since
3.0.0

wc_deprecated_function()

Wrapper for deprecated functions so we can apply some extra logic.

wc_deprecated_function(string $function, string $version[, string $replacement = null ]) : mixed
Parameters
$function : string

Function used.

$version : string

Version the message was added in.

$replacement : string = null

Replacement for the called function.

Tags
since
3.0.0

wc_deprecated_hook()

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
Parameters
$hook : string

The hook that was used.

$version : string

The version of WordPress that deprecated the hook.

$replacement : string = null

The hook that should have been used.

$message : string = null

A message regarding the change.

Tags
since
3.3.0

wc_caught_exception()

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
Parameters
$exception_object : Exception

The exception object.

$function : string = ''

The function which threw exception.

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

The args passed to the function.

Tags
since
3.3.0

wc_doing_it_wrong()

Wrapper for _doing_it_wrong().

wc_doing_it_wrong(string $function, string $message, string $version) : mixed
Parameters
$function : string

Function used.

$message : string

Message to log.

$version : string

Version the message was added in.

Tags
since
3.0.0

wc_deprecated_argument()

Wrapper for deprecated arguments so we can apply some extra logic.

wc_deprecated_argument(string $argument, string $version[, mixed $message = null ]) : mixed
Parameters
$argument : string
$version : string
$message : mixed = null
Tags
since
3.0.0

woocommerce_create_page()

woocommerce_create_page(mixed $slug[, mixed $option = '' ][, mixed $page_title = '' ][, mixed $page_content = '' ], mixed $post_parent) : mixed
Parameters
$slug : mixed
$option : mixed = ''
$page_title : mixed = ''
$page_content : mixed = ''
$post_parent : mixed
Tags
deprecated
2.1

woocommerce_readfile_chunked()

woocommerce_readfile_chunked(mixed $file[, mixed $retbytes = true ]) : mixed
Parameters
$file : mixed
$retbytes : mixed = true
Tags
deprecated
2.1

woocommerce_format_total()

Formal total costs - format to the number of decimal places for the base currency.

woocommerce_format_total(mixed $number) : string
Parameters
$number : mixed
Tags
access

public

deprecated
2.1

woocommerce_get_formatted_product_name()

Get product name with extra details such as SKU price and attributes. Used within admin.

woocommerce_get_formatted_product_name(WC_Product $product) : string
Parameters
$product : WC_Product
Tags
access

public

deprecated
2.1

woocommerce_legacy_paypal_ipn()

Handle IPN requests for the legacy paypal gateway by calling gateways manually if needed.

woocommerce_legacy_paypal_ipn() : mixed
Tags
access

public

get_product()

get_product([mixed $the_product = false ][, mixed $args = array() ]) : mixed
Parameters
$the_product : mixed = false
$args : mixed = array()
Tags
deprecated
3.0

woocommerce_protected_product_add_to_cart()

woocommerce_protected_product_add_to_cart(mixed $passed, mixed $product_id) : mixed
Parameters
$passed : mixed
$product_id : mixed
Tags
deprecated
3.0

woocommerce_load_persistent_cart()

woocommerce_load_persistent_cart(mixed $user_login, mixed $user) : mixed
Parameters
$user_login : mixed
$user : mixed
Tags
deprecated
3.0

woocommerce_add_to_cart_message()

woocommerce_add_to_cart_message(mixed $product_id) : mixed
Parameters
$product_id : mixed
Tags
deprecated
3.0

woocommerce_cart_totals_coupon_html()

woocommerce_cart_totals_coupon_html(mixed $coupon) : mixed
Parameters
$coupon : mixed
Tags
deprecated
3.0

woocommerce_cart_totals_shipping_method_label()

woocommerce_cart_totals_shipping_method_label(mixed $method) : mixed
Parameters
$method : mixed
Tags
deprecated
3.0

woocommerce_get_template_part()

woocommerce_get_template_part(mixed $slug[, mixed $name = '' ]) : mixed
Parameters
$slug : mixed
$name : mixed = ''
Tags
deprecated
3.0

woocommerce_get_template()

woocommerce_get_template(mixed $template_name[, mixed $args = array() ][, mixed $template_path = '' ][, mixed $default_path = '' ]) : mixed
Parameters
$template_name : mixed
$args : mixed = array()
$template_path : mixed = ''
$default_path : mixed = ''
Tags
deprecated
3.0

woocommerce_locate_template()

woocommerce_locate_template(mixed $template_name[, mixed $template_path = '' ][, mixed $default_path = '' ]) : mixed
Parameters
$template_name : mixed
$template_path : mixed = ''
$default_path : mixed = ''
Tags
deprecated
3.0

woocommerce_mail()

woocommerce_mail(mixed $to, mixed $subject, mixed $message[, mixed $headers = "Content-Type: text/html " ][, mixed $attachments = "" ]) : mixed
Parameters
$to : mixed
$subject : mixed
$message : mixed
$headers : mixed = "Content-Type: text/html "
$attachments : mixed = ""
Tags
deprecated
3.0

woocommerce_disable_admin_bar()

woocommerce_disable_admin_bar(mixed $show_admin_bar) : mixed
Parameters
$show_admin_bar : mixed
Tags
deprecated
3.0

woocommerce_create_new_customer()

woocommerce_create_new_customer(mixed $email[, mixed $username = '' ][, mixed $password = '' ]) : mixed
Parameters
$email : mixed
$username : mixed = ''
$password : mixed = ''
Tags
deprecated
3.0
woocommerce_set_customer_auth_cookie(mixed $customer_id) : mixed
Parameters
$customer_id : mixed
Tags
deprecated
3.0

woocommerce_update_new_customer_past_orders()

woocommerce_update_new_customer_past_orders(mixed $customer_id) : mixed
Parameters
$customer_id : mixed
Tags
deprecated
3.0

woocommerce_customer_bought_product()

woocommerce_customer_bought_product(mixed $customer_email, mixed $user_id, mixed $product_id) : mixed
Parameters
$customer_email : mixed
$user_id : mixed
$product_id : mixed
Tags
deprecated
3.0

woocommerce_customer_has_capability()

woocommerce_customer_has_capability(mixed $allcaps, mixed $caps, mixed $args) : mixed
Parameters
$allcaps : mixed
$caps : mixed
$args : mixed
Tags
deprecated
3.0

woocommerce_sanitize_taxonomy_name()

woocommerce_sanitize_taxonomy_name(mixed $taxonomy) : mixed
Parameters
$taxonomy : mixed
Tags
deprecated
3.0

woocommerce_get_filename_from_url()

woocommerce_get_filename_from_url(mixed $file_url) : mixed
Parameters
$file_url : mixed
Tags
deprecated
3.0

woocommerce_get_dimension()

woocommerce_get_dimension(mixed $dim, mixed $to_unit) : mixed
Parameters
$dim : mixed
$to_unit : mixed
Tags
deprecated
3.0

woocommerce_get_weight()

woocommerce_get_weight(mixed $weight, mixed $to_unit) : mixed
Parameters
$weight : mixed
$to_unit : mixed
Tags
deprecated
3.0

woocommerce_format_decimal()

woocommerce_format_decimal(mixed $number[, mixed $dp = false ][, mixed $trim_zeros = false ]) : mixed
Parameters
$number : mixed
$dp : mixed = false
$trim_zeros : mixed = false
Tags
deprecated
3.0

woocommerce_array_overlay()

woocommerce_array_overlay(mixed $a1, mixed $a2) : mixed
Parameters
$a1 : mixed
$a2 : mixed
Tags
deprecated
3.0

woocommerce_price()

woocommerce_price(mixed $price[, mixed $args = array() ]) : mixed
Parameters
$price : mixed
$args : mixed = array()
Tags
deprecated
3.0

woocommerce_hex_darker()

woocommerce_hex_darker(mixed $color[, mixed $factor = 30 ]) : mixed
Parameters
$color : mixed
$factor : mixed = 30
Tags
deprecated
3.0

woocommerce_hex_lighter()

woocommerce_hex_lighter(mixed $color[, mixed $factor = 30 ]) : mixed
Parameters
$color : mixed
$factor : mixed = 30
Tags
deprecated
3.0

woocommerce_light_or_dark()

woocommerce_light_or_dark(mixed $color[, mixed $dark = '#000000' ][, mixed $light = '#FFFFFF' ]) : mixed
Parameters
$color : mixed
$dark : mixed = '#000000'
$light : mixed = '#FFFFFF'
Tags
deprecated
3.0

woocommerce_get_order_id_by_order_key()

woocommerce_get_order_id_by_order_key(mixed $order_key) : mixed
Parameters
$order_key : mixed
Tags
deprecated
3.0

woocommerce_downloadable_file_permission()

woocommerce_downloadable_file_permission(mixed $download_id, mixed $product_id, mixed $order) : mixed
Parameters
$download_id : mixed
$product_id : mixed
$order : mixed
Tags
deprecated
3.0

woocommerce_downloadable_product_permissions()

woocommerce_downloadable_product_permissions(mixed $order_id) : mixed
Parameters
$order_id : mixed
Tags
deprecated
3.0

woocommerce_add_order_item()

woocommerce_add_order_item(mixed $order_id, mixed $item) : mixed
Parameters
$order_id : mixed
$item : mixed
Tags
deprecated
3.0

woocommerce_update_order_item_meta()

woocommerce_update_order_item_meta(mixed $item_id, mixed $meta_key, mixed $meta_value[, mixed $prev_value = '' ]) : mixed
Parameters
$item_id : mixed
$meta_key : mixed
$meta_value : mixed
$prev_value : mixed = ''
Tags
deprecated
3.0

woocommerce_add_order_item_meta()

woocommerce_add_order_item_meta(mixed $item_id, mixed $meta_key, mixed $meta_value[, mixed $unique = false ]) : mixed
Parameters
$item_id : mixed
$meta_key : mixed
$meta_value : mixed
$unique : mixed = false
Tags
deprecated
3.0

woocommerce_delete_order_item_meta()

woocommerce_delete_order_item_meta(mixed $item_id, mixed $meta_key[, mixed $meta_value = '' ][, mixed $delete_all = false ]) : mixed
Parameters
$item_id : mixed
$meta_key : mixed
$meta_value : mixed = ''
$delete_all : mixed = false
Tags
deprecated
3.0

woocommerce_get_order_item_meta()

woocommerce_get_order_item_meta(mixed $item_id, mixed $key[, mixed $single = true ]) : mixed
Parameters
$item_id : mixed
$key : mixed
$single : mixed = true
Tags
deprecated
3.0

woocommerce_get_endpoint_url()

woocommerce_get_endpoint_url(mixed $endpoint[, mixed $value = '' ][, mixed $permalink = '' ]) : mixed
Parameters
$endpoint : mixed
$value : mixed = ''
$permalink : mixed = ''
Tags
deprecated
3.0

woocommerce_nav_menu_items()

woocommerce_nav_menu_items(mixed $items, mixed $args) : mixed
Parameters
$items : mixed
$args : mixed
Tags
deprecated
3.0

woocommerce_nav_menu_item_classes()

woocommerce_nav_menu_item_classes(mixed $menu_items, mixed $args) : mixed
Parameters
$menu_items : mixed
$args : mixed
Tags
deprecated
3.0

woocommerce_product_dropdown_categories()

woocommerce_product_dropdown_categories([mixed $args = array() ][, mixed $deprecated_hierarchical = 1 ][, mixed $deprecated_show_uncategorized = 1 ][, mixed $deprecated_orderby = '' ]) : mixed
Parameters
$args : mixed = array()
$deprecated_hierarchical : mixed = 1
$deprecated_show_uncategorized : mixed = 1
$deprecated_orderby : mixed = ''
Tags
deprecated
3.0

woocommerce_walk_category_dropdown_tree()

woocommerce_walk_category_dropdown_tree([mixed $a1 = '' ][, mixed $a2 = '' ][, mixed $a3 = '' ]) : mixed
Parameters
$a1 : mixed = ''
$a2 : mixed = ''
$a3 : mixed = ''
Tags
deprecated
3.0

woocommerce_order_terms()

woocommerce_order_terms(mixed $the_term, mixed $next_id, mixed $taxonomy, mixed $index[, mixed $terms = null ]) : mixed
Parameters
$the_term : mixed
$next_id : mixed
$taxonomy : mixed
$index : mixed
$terms : mixed = null
Tags
deprecated
3.0

woocommerce_set_term_order()

woocommerce_set_term_order(mixed $term_id, mixed $index, mixed $taxonomy[, mixed $recursive = false ]) : mixed
Parameters
$term_id : mixed
$index : mixed
$taxonomy : mixed
$recursive : mixed = false
Tags
deprecated
3.0

woocommerce_terms_clauses()

woocommerce_terms_clauses(mixed $clauses, mixed $taxonomies, mixed $args) : mixed
Parameters
$clauses : mixed
$taxonomies : mixed
$args : mixed
Tags
deprecated
3.0

_woocommerce_term_recount()

_woocommerce_term_recount(mixed $terms, mixed $taxonomy, mixed $callback, mixed $terms_are_term_taxonomy_ids) : mixed
Parameters
$terms : mixed
$taxonomy : mixed
$callback : mixed
$terms_are_term_taxonomy_ids : mixed
Tags
deprecated
3.0

woocommerce_recount_after_stock_change()

woocommerce_recount_after_stock_change(mixed $product_id) : mixed
Parameters
$product_id : mixed
Tags
deprecated
3.0

woocommerce_change_term_counts()

woocommerce_change_term_counts(mixed $terms, mixed $taxonomies, mixed $args) : mixed
Parameters
$terms : mixed
$taxonomies : mixed
$args : mixed
Tags
deprecated
3.0

woocommerce_get_product_terms()

woocommerce_get_product_terms(mixed $object_id, mixed $taxonomy[, mixed $fields = 'all' ]) : mixed
Parameters
$object_id : mixed
$taxonomy : mixed
$fields : mixed = 'all'
Tags
deprecated
3.0

woocommerce_product_post_type_link()

woocommerce_product_post_type_link(mixed $permalink, mixed $post) : mixed
Parameters
$permalink : mixed
$post : mixed
Tags
deprecated
3.0

woocommerce_placeholder_img()

woocommerce_placeholder_img([mixed $size = 'woocommerce_thumbnail' ]) : mixed
Parameters
$size : mixed = 'woocommerce_thumbnail'
Tags
deprecated
3.0

woocommerce_get_formatted_variation()

woocommerce_get_formatted_variation([mixed $variation = '' ][, mixed $flat = false ]) : mixed
Parameters
$variation : mixed = ''
$flat : mixed = false
Tags
deprecated
3.0

woocommerce_scheduled_sales()