Skip to content

Instantly share code, notes, and snippets.

@kloon
Created February 18, 2014 13:09
Show Gist options
  • Save kloon/9070636 to your computer and use it in GitHub Desktop.
Save kloon/9070636 to your computer and use it in GitHub Desktop.
WooCommerce add weight unit after price
<?php
// Add R xx.xx per KG
add_action( 'woocommerce_price_html', 'wc_custom_price', 10, 2 );
function wc_custom_price( $price, $product ) {
return sprintf( __( '%s per KG', 'woocommerce' ), woocommerce_price( $product->get_price() ) );
}
?>
@xhtmler
Copy link

xhtmler commented Sep 4, 2014

sorry I am newbie to woo and wordpress, Where would I put the above code and could I change the per KG to per LB depending on product?

@nilssanders
Copy link

Hi. Is there a way to get it running with product variations?

@brandonecarr
Copy link

@xhtmler This code would be added to your theme's functions.php file. Hopefully, you're using a child theme. If so, you would go to wp-content/themes/yourchildtheme/functions.php Add the code after the <?php tag. Good luck!

@yrubashk
Copy link

yrubashk commented Jun 3, 2016

@brandonecarr I am using the Flatsome theme where do I go to add the above code?
Thank you!

@rodrigovilla
Copy link

Thanks!

@eversionsystems
Copy link

You get your sites weight unit using the following.
get_option('woocommerce_weight_unit' )

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