Updates, Tips & Tricks

Updates as Released, Plus My Personal Collection Of WordPress Best Practices

How to Customize the WooCommerce Add to Cart Message

30 March

Here’s a fun one. Let’s say you want to rename Cart to something else, like Bag or Briefcase. It can be tricky to find all of the places to make that change. You can, of course, edit the templates within WooCommerce, or even copy the templates into your theme to avoid crushing your changes when you upgrade.

Here’s a simple way to customize the WooCommerce Add to Cart Message and change Cart to Briefcase. Add the following to functions.php.

// Custom Cart Message
add_filter( 'woocommerce_add_to_cart_message', 'custom_add_to_cart_message' );
function custom_add_to_cart_message ($message) {
    global $woocommerce;
    // Output success messages
        $custom_message    = sprintf('%s %s', __('Product successfully added to your ', 'woocommerce'), get_permalink(woocommerce_get_page_id('cart')), __('Briefcase', 'woocommerce'));
    global $is_cart_added;
    $is_cart_added = 1;
    return $custom_message;
}
No comments yet.

Leave a Reply