Skip to content

Instantly share code, notes, and snippets.

@woogist
Last active April 28, 2019 17:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save woogist/6380491 to your computer and use it in GitHub Desktop.
Save woogist/6380491 to your computer and use it in GitHub Desktop.
WooCommerce Measurement Price Calculator custom unit convert
<?php
add_filter( 'wc_measurement_price_calculator_conversion_table', 'wc_measurement_price_calculator_conversion_table' );
/**
* This converts standard units to all other compatible units
*/
function wc_measurement_price_calculator_conversion_table( $conversion_table ) {
// 1 ft = 1/18228.3465 leagues
$conversion_table['ft']['league'] = array( 'factor' => 18228.3465, 'inverse' => true );
// 1 m = 0.000179985601 leagues
$conversion_table['m']['league'] = array( 'factor' => 0.000179985601 );
return $conversion_table;
}
@CasperBr
Copy link

Hello,

got a question for this. Where should i put this in order for it to work?

Greetz and many thanks,

Casper

@tdonovic
Copy link

Put this in functions.php

@onebook0505
Copy link

Hi @bekarice,why woocommerce_area_unit is not working?

in measurement tab, if not enabled Calculated Price,how can i show the product dimensions in the cart?

WooCommerce version 3.5.7
WooCommerce Measurement Price Calculator version 3.14.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment