1. Documentation /
  2. Useful Core Functions

Useful Core Functions

The following useful functions are found in includes/wc-core-functions.php and can be used by themes and plugins.

wc_mail

↑ Back to top
Used to send an email using the WooCommerce email templates.
wc_mail( $to, $subject, $message, $headers = "Content-Type: text/htmlrn", $attachments = "" )

wc_get_page_id( $pagename )

↑ Back to top
Gets a WooCommerce page ID by name, e.g. thankyou
wc_get_page_id( $page )

wc_price( $price, $args )

↑ Back to top
Formats a passed price with the correct number of decimals and currency symbol.
wc_price( $price, $args = array() )
The $args array has an option called ex_tax_label – if true then an ‘excluding tax’ message will be appended.

wc_clean( $var )

↑ Back to top
Trims and strips tags from a string ($var).
wc_clean( $var )

wc_get_dimension( $dim, $to_unit )

↑ Back to top
Takes a measurement (dim) measured in WooCommerce’s dimension unit and converts it to the target unit  ($to_unit).
wc_get_dimension( 10, 'lbs' )

wc_get_weight( $weight, $to_unit )

↑ Back to top
Takes a weight ($weight) weighed in WooCommerce’s weight unit and converts it to the target weight unit  ($to_unit).
wc_get_weight( 10, 'lbs' )