Support » Developing with WordPress » Gettext and Plugin

  • After add something to cart and then choose a Pickup Location
    The “Schedule a pickup appointment *” pops up.

    I need to change this text to “Select Date” and having trouble with GETTEXT.
    The other two changes are working. The original text is coming from a plugin
    called woocommerce-shipping-local-pickup-plus.

    Any help is so appreciated! I am banging my head. thank you

    I have tried woocommerce and woocommerce-shipping-local-pickup-plus for the theme_text_domain thinking this was the problem.

    /**
    * Change text strings
    *
    * @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
    */
    function my_text_strings( $translated_text, $text, $domain ) {
    switch ( $translated_text ) {
    case ‘Cart totals’ :
    $translated_text = __( ‘Order Total’, ‘woocommerce’ );
    break;
    case ‘Pickup Location’ :
    $translated_text = __( ‘Select Location’, ‘woocommerce’ );
    break;
    case ‘Schedule a pickup appointment’ :
    $translated_text = __( ‘Select Date’, ‘woocommerce-shipping-local-pickup-plus’ );
    break;
    }
    return $translated_text;
    }
    add_filter( ‘gettext’, ‘my_text_strings’, 20, 3 );

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Maybe the star is causing the issue? Have you tried checking if the string starts with “Schedule a pickup appointment” instead? ie:

    $check_text = 'Schedule a pickup appointment';
    
    if(substr($translated_text, 0, strlen($check_text)) === $check_text) {
       // do your thing
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Gettext and Plugin’ is closed to new replies.