{"id":54972,"date":"2020-01-17T21:45:48","date_gmt":"2020-01-17T20:45:48","guid":{"rendered":"https:\/\/samuelchopard.ch\/wiki\/?p=54972"},"modified":"2020-01-24T16:21:45","modified_gmt":"2020-01-24T15:21:45","slug":"edit-the-added-to-cart-message","status":"publish","type":"post","link":"https:\/\/samuelchopard.ch\/wiki\/library\/edit-the-added-to-cart-message\/","title":{"rendered":"Edit the \u201cadded to cart\u201d message"},"content":{"rendered":"<p><!--more--><br \/>\nPaste the following in functions.php:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\">\/* Edit WooCommerce added to cart message *\/\r\nadd_filter ( 'wc_add_to_cart_message', 'wc_add_to_cart_message_filter', 10, 2 );\r\nfunction wc_add_to_cart_message_filter($message, $product_id = null) {\r\n    $titles[] = get_the_title( $product_id );\r\n    $titles = array_filter( $titles );\r\n    $added_text = sprintf( _n( '%s has been added to your cart.', '%s have been added to your cart.', sizeof( $titles ), 'woocommerce' ), wc_format_list_of_items( $titles ) );\r\n    $message = sprintf( '%s<\/pre>\n<p><a class=\"button\" target=\"_blank\" href=\"%s\">%s<\/a><a class=\"button\" target=\"_blank\" href=\"%s\">%s<\/a><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\">',\r\n                    esc_html( $added_text ),\r\n                    esc_url( wc_get_page_permalink( 'checkout' ) ),\r\n                    esc_html__( '', 'woocommerce' ),\r\n                    esc_url( wc_get_page_permalink( 'cart' ) ),\r\n                    esc_html__( 'Voir le panier \u2192', 'woocommerce' ));\r\n\r\n    return $message;\r\n}<\/pre>\n<p>Edit text as needed.<\/p>\n<p>Source: <a target=\"_blank\" href=\"https:\/\/stackoverflow.com\/questions\/25880460\/woocommerce-how-to-edit-the-added-to-cart-message\">https:\/\/stackoverflow.com\/questions\/25880460\/woocommerce-how-to-edit-the-added-to-cart-message<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"Paste the following in functions.php: \/* Edit WooCommerce added to cart message *\/ add_filter ( 'wc_add_to_cart_message', 'wc_add_to_cart_message_filter', 10, 2 ); [...]","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[52,370,327],"class_list":["post-54972","post","type-post","status-publish","format-standard","hentry","category-woocommerce","tag-cart","tag-message","tag-woocommerce"],"_links":{"self":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/54972","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/comments?post=54972"}],"version-history":[{"count":2,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/54972\/revisions"}],"predecessor-version":[{"id":54980,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/54972\/revisions\/54980"}],"wp:attachment":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/media?parent=54972"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/categories?post=54972"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/tags?post=54972"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}