1

I am trying to change the text "Booking Cost" which is displayed when a user selects dates on the WooCommerce Booking Calendar. I want to change it to "Guide Price"

I tried loco translate but this didn't work.

I need the "Booking Cost" text to say "Guide Price" instead.

mujuonly
  • 11,370
  • 5
  • 45
  • 75

4 Answers4

1

There is a filter for this:

add_filter('woocommerce_bookings_booking_cost_string', function( $string ) { return 'New String'; } );

Just change 'New String' to whatever text you require, and add the snippet to your functions.php file.

You will end up with something like this: Booking Cost text changed

Ben Roberts
  • 106
  • 1
  • 5
0
function wc_booking_field_strings( $translated_text, $text, $domain ) {

    switch ( $translated_text ) {
        case 'Booking Cost' :
            $translated_text = __( 'Guide Price', 'text-domain' );
            break;
    }
    return $translated_text;
}
add_filter( 'gettext', 'wc_booking_field_strings', 20, 3 );

Similar case here

mujuonly
  • 11,370
  • 5
  • 45
  • 75
  • Thanks Mujuonly, I added this to my child theme's functions.php file but had no effect. It's still reading 'Booking Cost'. Appreciate the help. – T-BoneSteak Apr 01 '19 at 08:19
0

woocommerce-bookings\woocommerce-bookings\includes\admin\class-wc-bookings-ajax.php

wp_send_json( array(
        'result' => 'SUCCESS',
        'html'   => apply_filters( 'woocommerce_bookings_booking_cost_string', __( 'Booking cost', 'woocommerce-bookings' ), $product ) . ': <strong>' . wc_price( $display_price ) . $price_suffix . '</strong>',
    ) );
}
0
$('.wc-bookings-booking-form').click(function(){
   $( document ).ajaxComplete(function() {
     console.log($('.wc-bookings-booking-cost').text());
     var text = $('.wc-bookings-booking-cost').text().replace('Booking Cost', 'Estimate Price');
     $('.wc-bookings-booking-cost').text(text);
   });
 });

Find out what triggers Ajax to get to calculate the cost in your case and replace .wc-bookings-booking-form with your class.

Adam
  • 1