0

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 Answers3

0

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

amarinediary
  • 4,930
  • 4
  • 27
  • 45
  • 1
    Thank you very much. I reflected it in the JS file that the support of the word press theme CUSTOM JAVASCRIPT and The Event Calenar taught me, but it did not change.              event-tickets/src/resources/js/tickets-block.js Is the file to be updated different? – hiro0913jp Jul 08 '20 at 03:55
  • In Wordpress plugins are initiated before the function.php file, so it is safe to assume that if you load it via the function.php file it will work; An other option would be to load it via the plugin JS file itself. – amarinediary Jul 08 '20 at 09:58
  • When I reflected the code in the function.php of the child theme, I got the following error. ⇒ syntax error, unexpected'(', expecting variable (T_VARIABLE) or'{' or'$' Regarding JS, even if it was directly overwritten in event-tickets/src/resources/js/tickets-block.js or reflected in Custom Javascript of Wordpress Theme, it did not change. – hiro0913jp Jul 08 '20 at 11:49
0

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

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.