Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter Koli14

    (@koli14)

    This change the button text, but after a moment it will be replaced with ‘Proceed to Barion’:

    add_filter( 'woocommerce_order_button_text', 'woo_custom_order_button_text',100 );
    function woo_custom_order_button_text() {
        return __( 'Confirm and Pay', 'woocommerce' );
    }
    Thread Starter Koli14

    (@koli14)

    I could solve the issue with the following code:

    <?php
    add_filter( 'gettext', 'misha_custom_paypal_button_text', 20, 3 );
    function misha_custom_paypal_button_text( $translated_text, $text, $domain ) {
    
      if( $translated_text == 'Proceed to Barion' ) {
        $translated_text = 'Confirm and Pay'; // new button text is here
      }
    
      return $translated_text;
    }
    Thread Starter Koli14

    (@koli14)

    After updating to the newest version (Version 3.0.3) my previous solution is not working anymore. Any idea how to fix it?

    Plugin Author szelpe

    (@szelpe)

    This text hasn’t changed in the new version.

    Thread Starter Koli14

    (@koli14)

    I tried it now on a freshly installed test site, and my code works with plugin version 2.5.1, but with 3.0.1 and above it’s not working.

    My code:

     
    <?php
    add_filter( 'gettext', custom_checkout_button_text', 20, 3 );
    function custom_checkout_button_text( $translated_text, $text, $domain ) {
    
      if( $translated_text == 'Proceed to Barion' ) {
        $translated_text = 'Confirm and Pay'; // new button text is here
      }
    
      return $translated_text;
    }
    
    Plugin Author szelpe

    (@szelpe)

    What language are you using on your site?

    Thread Starter Koli14

    (@koli14)

    English.
    https://dev.digitalnomadhungary.com/checkout/

    • This reply was modified 5 years, 2 months ago by Koli14.
    Plugin Author szelpe

    (@szelpe)

    How did you try to debug your code?

    Thread Starter Koli14

    (@koli14)

    I use these settings in my test sites:

    define( 'WP_DEBUG', true );
    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(E_ALL);
    define( 'WP_DEBUG_LOG', true );
    define( 'SCRIPT_DEBUG', true );

    Out of this I have no idea how could I debug it.

    • This reply was modified 5 years, 2 months ago by Koli14.
    Plugin Author szelpe

    (@szelpe)

    If I had to debug your code I’d certainly start by printing the value of the $translated_text variable.

    Thread Starter Koli14

    (@koli14)

    You are on the right way, I logged the $translated_text, and it’s never ‘Proceed to Barion’, but ‘Place order’. But even if I change my function if ($translated_text == 'Proceed to Barion' || $translated_text == 'Place order') {, it appears for a moment correct but some script modifies it later on pageload

    I also tried to change the text with JavaScript, and it does change it, but probably some other JavaScript change it tp ‘Proceed to Barion’.
    The button has the text first: ‘Place order’ -> then I change it with JS to ‘Confirm and Pay’ and then it changes again to ‘Proceed to Barion’.

    I tried it with 3 themes: Avada, StoreFront and Twenty Nineteen

    • This reply was modified 5 years, 2 months ago by Koli14.
    Thread Starter Koli14

    (@koli14)

    I found what cause it: in /woocommerce/assets/js/frontend/checkout.js from 114:

    if ( $( this ).data( 'order_button_text' ) ) {
        $( '#place_order' ).text( $( this ).data( 'order_button_text' ) );
    }
    Thread Starter Koli14

    (@koli14)

    But I still did not find a proper solution.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Change the text ‘Proceed to Barion’’ is closed to new replies.