Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

163
Views
Woocommerce add thousand separator in custom price field

I want to add a thousand separator in custom input field in Woocommerce product page.

this is my code:

jQuery(document).ready(function () {
  jQuery(document).on('input', '.number-separator', function (e) {
    if (/^[0-9.,]+$/.test(jQuery(this).val())) {
      jQuery(this).val(
        parseFloat(jQuery(this).val().replace(/,/g, '')).toLocaleString('en')
      );
    } else {
      jQuery(this).val(
        jQuery(this)
          .val()
          .substring(0, jQuery(this).val().length - 1)
      );
    }
  });
}); 
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="text" name="tmcp_textfield_6" class="number-separator" value="" >

Everything seems right, But when I add the product to the cart Only the first part of the price is added.

For example, when I enter the number 5,000,000 Only number 5 will be added to the cart

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

from funcion file

// Woocommerce add thousand separator in custom price field
add_filter('woocommerce_price_format', 'digitalize_price_format');
function digitalize_price_format($format) {
    $format['decimal_point'] = '.';
    $format['thousand_sep'] = ',';
    return $format;
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!