Useful Core Functions

You are here:

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

wc_mail

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 )

Gets a WooCommerce page ID by name, e.g. thankyou

wc_get_page_id( $page )

wc_price( $price, $args )

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 )

Trims and strips tags from a string ($var).

wc_clean( $var )

wc_get_dimension( $dim, $to_unit )

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 )

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' )
Was this article helpful?
Dislike 0
Views: 11