I recently had a client for whom I had added a separate line to their WooCommerce checkout process specifically for handling fees (they needed it displayed and calculated separately from the actual shipping charges). But now that meant that one line was labeled “Shipping and Handling” and then another line was named “Handling”. This was rather confusing. So I needed a function that changed that text without hacking the core files of WooCommerce. Here’s the solution if you find you need it. Note: This is not an uncommon need in WooCommerce so this function is probably found in many places all over the web. I’m keeping it here as much for my own future reference as to provide it to you.

Remember that this code goes inside your theme functions.php file.

// change shipping and handling text to "Delivery Charges"

add_filter('gettext', 'translate_reply');
add_filter('ngettext', 'translate_reply');

function translate_reply($translated) {
$translated = str_ireplace('Shipping and Handling', 'Delivery Charges', $translated);
return $translated;
}

Just change ‘Delivery Charges’ to whatever you want the line to be titled, and you’re done!

thePixelPixie.com - WordPress boutique

Subscribe and receive my FREE eBook


4 MISTAKES You’re Making on Your Website that are Costing You MONEY!

  • This field is for validation purposes and should be left unchanged.

The Author

Save

2 responses to “Adding WooCommerce Product Categories & Products to Your Menu”

  1. Hi. Thanks for this. It’s very useful.

    Is there a way to modify this one so that HTML tags in the title are not encoded into entities?

    // Change the description tab heading to product name
    add_filter( ‘woocommerce_product_description_heading’, ‘wc_change_product_description_tab_heading’, 10, 1 );
    function wc_change_product_description_tab_heading( $title ) {
    global $post;
    return $post->post_title;
    }
    We’re using italics in some product titles, which generally works fine in most places, except this function where they are encoded into their HTML entities, and thus the italic tags are shown.

    Thanks,
    Michael

    • Hi Michael,
      I apologize for not seeing your comment before now. Unfortunately, I’m afraid I don’t have an answer for you. But I’m going to look into it for you and see if I can find an answer. That said, if you’ve already come up with an answer, I’d love to know your solution!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Ready to chat about how ThePixelPixie can help?