Skip to content

Instantly share code, notes, and snippets.

@woogist
Last active December 21, 2015 22:59
Show Gist options
  • Save woogist/6379275 to your computer and use it in GitHub Desktop.
Save woogist/6379275 to your computer and use it in GitHub Desktop.
Measurement Price Calculator sample code for adding a custom unit
<?php
add_filter( 'woocommerce_catalog_settings', 'add_woocommerce_dimension_unit_league' );
/**
* This adds the new unit to the WooCommerce admin
*/
function add_woocommerce_dimension_unit_league( $settings ) {
foreach ( $settings as &$setting ) {
if ( 'woocommerce_dimension_unit' == $setting['id'] ) {
$setting['options']['league'] = __( 'League' ); // new unit
}
}
return $settings;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment