skip to Main Content

First, I don’t use product price decimal at my local currency; decimal=0. And I want to change product price from 123,450 to 123,000 or 124,000. I searched many and many posting on the internet but I could not find any right answer for my needs. How can I do these price changes?

2

Answers


  1. Copy and paste script and give me a review feedback.

    <input type = "number" name="a" id="a">
    <input type= "button"  onClick="calculation()">
    <script  type="text/javascript">
    function calculation()
    {
       var converted = document.getElementById('a');
       var decimal = (converted - parseInt(converted, 10));
       decimal = Math.round(decimal * 10);
       if (decimal == 5) { return (parseInt(converted, 10)-0.5); }
       if ( (decimal < 5) ) {
            total.value =  (parseInt(converted, 10)-0.5);
            //total.value = Math.round(converted);
       } else {
            total.value = (parseInt(converted, 10)+1);
       }            
    }
    </script>
    
    Login or Signup to reply.
  2. add_filter( 'woocommerce_get_price', 'round_price_product', 10, 1);
    
    function round_price_product( $price ){
    
        // Return rounded price
        return ceil( $price ); 
    }
    

    Add this to your active theme functions.php

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search