How to delete .00 when Event Tickets $ is displayed as ¥

93 views Asked by At

I am building a ticket sales test site using Event Tickets. https://wordpress.org/plugins/event-tickets/

This is the modal part of "Tickets" on this page. https://naturetest.net/2020/07/02/mcvities-digestive-biscuits-advert-kittens/

Originally the $ display was changed from the management screen to the ¥ display, but the .00 part is not necessary in the ¥ display. I would like to display ¥20 for $20.00, but would you like to know how to erase the .00 part?

3

There are 3 answers

3
amarinediary On

START EDIT 1

If array( jquery ) match the name given to YOUR JQuery file when it is enqueue it should be working, if not it's probably because for some reason the plugins load after.

We need to load the script AFTER the plugin and AFTER JQuery, we can try to set a timeout of a few second, play around a bit with it and tell me if that's working. (this is my last idea beside loading it straight away from the JS plugin file).

setTimeout( function() {

  if ( $( ".tribe-amount:contains('.00')" ) ) {

    $('.tribe-amount').html( $('.tribe-amount').html().substring(0,$('.tribe-amount').html().length - 3) );

  };

}, 10);

I've also made a codepen to show you that it is working on my end. https://codepen.io/amarinediary/pen/ZEQoorj

END EDIT 1


START INITIAL

the following should work just fine, add it to your js script file. Don't hesitate to tell me if it works, or if you need anything else

$( document ).ready( function() {

  if ( $( ".tribe-amount:contains('.00')" ) ) {

    $('.tribe-amount').html( $('.tribe-amount').html().substring(0,$('.tribe-amount').html().length - 3) );

  };

} );

END INITIAL

0
hiro0913jp On

I added the following to the function.php of the WordPress child theme to call the Javascript.

function add_my_scripts() {
  wp_enqueue_script( 
    'base-script', 
    get_theme_file_uri( '/javascript.js' ), 
    array( 'jquery' ), 
    '20200708', 
    false
  );
}
add_action('wp_enqueue_scripts', 'add_my_scripts');

Next, I made javascript.js directly under the child theme of WordPress and put the following code.

$( document ).ready( function() {

  if ( $( ".tribe-amount:contains('.00')" ) ) {

    $('.tribe-amount').html( $('.tribe-amount').html().substring(0,$('.tribe-amount').html().length - 3) );

  };

} );

It is not reflected, but is something wrong?

0
hiro0913jp On

Thank you for your consultation. I was able to solve it by modifying the following file. event-tickets/src/Tribe/Commerce/Currency.php

$decimals = apply_filters('tribe_format_amount_decimals', 2 ); It was made possible by changing 2 to 0.

Thank you.