From 97269fc5d9e7b95de617081095aa250ba3fd7824 Mon Sep 17 00:00:00 2001 From: Andrew Lazarus Date: Thu, 5 Jul 2018 16:10:32 +0200 Subject: [PATCH 1/2] Added filter on item name in quotes Filter added to item in quotes. Initially was thinking that is it needed to translate the quotes only? I can't find any languages that do this specifically, but if it's a RTL language, perhaps you'd swap around the quote direction. The function `wc_add_to_cart_message` gives you the filter `wc_add_to_cart_message` to play with, but is already set in stone as HTML, and if you truly want to change the HTML of this message, you would need to rewrite the function. Simply adding `` to the product title is not possible without preg_replacing or hooking into gettext --- includes/wc-cart-functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/wc-cart-functions.php b/includes/wc-cart-functions.php index 0da8c1281ba..fcdd04613a6 100644 --- a/includes/wc-cart-functions.php +++ b/includes/wc-cart-functions.php @@ -107,7 +107,7 @@ function wc_add_to_cart_message( $products, $show_qty = false, $return = false ) foreach ( $products as $product_id => $qty ) { /* translators: %s: product name */ - $titles[] = ( $qty > 1 ? absint( $qty ) . ' × ' : '' ) . sprintf( _x( '“%s”', 'Item name in quotes', 'woocommerce' ), strip_tags( get_the_title( $product_id ) ) ); + $titles[] = ( $qty > 1 ? absint( $qty ) . ' × ' : '' ) . apply_filters( 'wc_add_to_cart_item_name_in_quotes', sprintf( _x( '“%s”', 'Item name in quotes', 'woocommerce' ), strip_tags( get_the_title( $product_id ) ) ), $product_id ); $count += $qty; } From d49f02a4e60f1a787e012d7d6779f358e600ba02 Mon Sep 17 00:00:00 2001 From: Andrew Lazarus Date: Fri, 6 Jul 2018 19:04:08 +0200 Subject: [PATCH 2/2] Updated prefix in filter --- includes/wc-cart-functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/wc-cart-functions.php b/includes/wc-cart-functions.php index fcdd04613a6..fb07c970c14 100644 --- a/includes/wc-cart-functions.php +++ b/includes/wc-cart-functions.php @@ -107,7 +107,7 @@ function wc_add_to_cart_message( $products, $show_qty = false, $return = false ) foreach ( $products as $product_id => $qty ) { /* translators: %s: product name */ - $titles[] = ( $qty > 1 ? absint( $qty ) . ' × ' : '' ) . apply_filters( 'wc_add_to_cart_item_name_in_quotes', sprintf( _x( '“%s”', 'Item name in quotes', 'woocommerce' ), strip_tags( get_the_title( $product_id ) ) ), $product_id ); + $titles[] = ( $qty > 1 ? absint( $qty ) . ' × ' : '' ) . apply_filters( 'woocommerce_add_to_cart_item_name_in_quotes', sprintf( _x( '“%s”', 'Item name in quotes', 'woocommerce' ), strip_tags( get_the_title( $product_id ) ) ), $product_id ); $count += $qty; }