• Resolved Erik HaagenStuff

    (@erik-haagenstuff)


    Hello,

    This is really more of a feature request.

    I’ve used this is my child theme functions PHP….
    function my_change_wrap_prompt( $prompt ) {
    // your newly worded prompt below, after $prompt =, between ” apostrophes
    // cannot contain ‘ as punctuation unless escaped with a \,
    $prompt = ‘Is this a gift?’;
    return $prompt;
    }
    function my_add_wcwgp_filter() {
    add_filter( ‘wcgwp_add_wrap_prompt’, ‘my_change_wrap_prompt’, 11, 1 );
    }
    add_action( ‘after_setup_theme’, ‘my_add_wcwgp_filter’ );

    function my_change_wrap_button( $prompt ) {
    // your newly worded prompt below, after $prompt =, between ” apostrophes
    // cannot contain ‘ as punctuation unless escaped with a \,
    $prompt = ‘Submit Gift Options’;
    return $prompt;
    }
    function my_add_wcwgp_button_filter() {
    add_filter( ‘wcgwp_add_wrap_button_text’, ‘my_change_wrap_button’, 11, 1 );
    }
    add_action( ‘after_setup_theme’, ‘my_add_wcwgp_button_filter’ );

    Could the plugin be modified to enable me to change the “Add Gift Wrap Message”?

    I know I can copy the appropriate .php file to my child theme and modify it there, but then I have to keep track of things and check release notes. It would be so much cleaner to use a filter as above.

    Thank you in advance for your consideration. I appreciate the plugin, we are using it on my wife’s store.

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

Viewing 13 replies - 1 through 13 (of 13 total)
  • Hello @erik-haagenstuff

    Hopefully I got this right in version 4.3.1, which I just released. The filter is now ‘wcgwp_add_wrap_message’ for “Add Gift Wrap Message.” Does this help?

    Thank you friend. ??

    Hi again @erik-haagenstuff

    I am hoping version 4.3.1 worked out for you. Has it? If so can you close this support ticket? Thank you again!!

    Hi guys!

    So I’m not very well-versed in PHP at ALL and I wanted to know if you could send me the exact string to add to change the “Add Gift Wrap to Order” text?

    Thank you!

    P.S I love this plugin ??

    Thanks @graphicbird01,

    There are three ways to translate every string in this plugin. One is the standard way, l10n. More on that here

    The second is by using included hooks. The hook you’d need for that string is ‘wcgwp_add_wrap_button_text’, and you’d use code like this in your functions.php file (more info in the FAQ on how to include more PHP in your WordPress installation):

    function my_custom_wrap_button_text( $text ) {
        $text = 'Whatever you want to say.'; // change this!
        return $text;
    }
    add_filter( 'wcgwp_add_wrap_button_text', 'my_custom_wrap_button_text', 11, 1 );
    

    And the third is by using the included overrideable templates. There is also information about this in the FAQ.

    The rest is up to you! If you want more done for you, the Premium version has a built-in string translator where you just enter what you want the plugin to say in the settings.

    Thanks again!

    Thread Starter Erik HaagenStuff

    (@erik-haagenstuff)

    Thanks @littlepackage. I upgraded to 4.3.1, which over-wrote my edit to the plugin files so the message reverted to the standard. Then I added to child theme functions.php using the new filter and it worked great.

    For anyone reading who wants to do the same, this is what I added…

    function my_gift_message_prompt( $prompt ) {
    // your newly worded prompt below, after $prompt =, between ” apostrophes
    // cannot contain ‘ as punctuation unless escaped with a \,
    $prompt = ‘Add Gift Note’;
    return $prompt;
    }
    function my_gift_message_filter() {
    add_filter( ‘wcgwp_add_wrap_message’, ‘my_gift_message_prompt’, 11, 1 );
    }
    add_action( ‘after_setup_theme’, ‘my_gift_message_filter’ );

    Hi @erik-haagenstuff

    That’s a bummer about editing core files… a hard lesson for anyone. Sorry that happened to you! But I’m glad you found a more permanent fix.

    So you (and anyone else reading this) know, you could also use the the simpler:

    function custom_gift_message_prompt( $prompt ) {
        // your newly worded prompt below, after $prompt =, between " apostrophes
        // cannot contain ' as punctuation unless escaped with a \,
        $prompt = 'Add Gift Note';
        return $prompt;
    }
    add_filter( 'wcgwp_add_wrap_message', 'custom_gift_message_prompt', 11, 1 );

    Thank you ??

    Thread Starter Erik HaagenStuff

    (@erik-haagenstuff)

    Not a bummer! I fully expected it. I had never edited a plugin/theme directly before so it was fun to test and see it work as expected.

    I tried the simpler version and it worked great, also for the two buttons text.

    Hi Little Packer! First off, thanks for this amazing plugin and the 6 years you dedicated to it. It’s really your toddler now!

    Thanks also for the snippet to change the message. The problem I have is that this hook only changes the message on the “Button” that adds the wrapping product to the order. In my case, I would like to change the text of the hyperlink that shows the wrapping options when clicked.

    Is there another hook for that ? Now it says “Add gift wrap?”. I would like to show something like “Click for gift options” as my use case also provides a “Send no bill” option that it’s not actually a wrapping options.

    Thanks and I’m definitely buying the pro version. Hope you get something from there.

    Hi @thedrap

    Thanks for your kind words. This actually becomes a moot point if you buy the plus version because it has a built-in string translator. However, it sounds like you just need to find the correct hook for the string you want to translate. The one I gave above is just an example, and only translates the “Add Gift Wrap Message:” text. Sounds like the hook you want is ‘wcgwp_add_wrap_prompt’ and the PHP becomes:

    function custom_gift_wrap_prompt( $prompt ) {
        $prompt = 'Click for gift options';
        return $prompt;
    }
    add_filter( 'wcgwp_add_wrap_prompt', 'custom_gift_wrap_prompt', 11, 1 );

    If you need to change further lines, you can look through the included templates (in the templates/wcgwp folder) or the classes/wcgw-wrapping.php file to find the correct hooks to use filters to change text.

    You could also translate the text in the usual way, using localization. I’ll leave that up to you.

    Amazing!! Yes.. I didn’t know where to find those hooks now I do!

    You’re a rock star.

    Have a wonderful evening!

    Would it be possible to remove the box ‘add a gift message’ box completely?

    @szimmer20 I replied to this question on another post of yours.

    Thank you!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Changing “Add Gift Wrap Message”’ is closed to new replies.