• Resolved Taajuus

    (@taajuus)


    I’m working on site that sells social media promoters. I want to use product WEIGHT as another purpose, in this case followers. So if product (person) has 50.000 followers, I set weight to 50.000 grams. This displays as followers in frontend product page and I have code sniplet that sums up all cart “weights” and displays “Total reach:” in cart summary.

    Everything works as expected, but I’d like to hide weight unit in frontend. So I want it to show just “50.000”, not “50.000 g”.

    Any ideas how to strip off this weight unit, in this case grams = “g” ?

Viewing 2 replies - 1 through 2 (of 2 total)
  • This works in the additional information tab, is that where you mean?

    add_filter( 'woocommerce_format_weight', 'custom_weight_format', 40, 2 );
    function custom_weight_format($weight_string, $weight) {
      return  $weight.' followers';
    }
    
    Thread Starter Taajuus

    (@taajuus)

    Perfect. Thank you!

    • This reply was modified 7 years, 10 months ago by Taajuus.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hide weight unit (for example kg) in frontend’ is closed to new replies.