{"id":54981,"date":"2020-01-24T16:24:45","date_gmt":"2020-01-24T15:24:45","guid":{"rendered":"https:\/\/samuelchopard.ch\/wiki\/?p=54981"},"modified":"2020-01-24T16:25:30","modified_gmt":"2020-01-24T15:25:30","slug":"display-remaining-amount-for-free-shipping-in-cart","status":"publish","type":"post","link":"https:\/\/samuelchopard.ch\/wiki\/library\/display-remaining-amount-for-free-shipping-in-cart\/","title":{"rendered":"Display remaining amount for free shipping in cart"},"content":{"rendered":"<p><!--more--><br \/>\nPaste the following code in functions.php:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\">\r\n\/* Display remaining amount for free shipping in cart *\/\r\nadd_action( 'woocommerce_before_cart', 'bbloomer_free_shipping_cart_notice' );  \r\nfunction bbloomer_free_shipping_cart_notice() {\r\n$min_amount = 25; \/\/change this to your free shipping threshold\r\n$current = WC()-&gt;cart-&gt;cart_contents_total;\r\nif ( $current &lt; $min_amount ) {\r\n   $added_text = esc_html__(&#039;Il ne manque que&#039;, &#039;woocommerce&#039; ) . wc_price( $min_amount - $current ) . esc_html__(&#039;pour profiter de la livraison gratuite.&#039;, &#039;woocommerce&#039; );\r\n   $return_to = apply_filters( &#039;woocommerce_continue_shopping_redirect&#039;, wc_get_raw_referer() ? wp_validate_redirect( wc_get_raw_referer(), false ) : wc_get_page_permalink( &#039;shop&#039; ) );\r\n   $notice = sprintf( &#039;<a target=\"_blank\" href=\"%s\" class=\"button wc-forward\">%s<\/a> %s', esc_url( $return_to ), esc_html__( 'Continue Shopping', 'woocommerce' ), $added_text );\r\n   wc_print_notice( $notice, 'notice' );\r\n}\r\n}<\/pre>\n<p>Edit text and shipping threshold as needed.<\/p>\n<p>Source: <a target=\"_blank\" href=\"https:\/\/businessbloomer.com\/woocommerce-add-need-spend-x-get-free-shipping-cart-page\/\">https:\/\/businessbloomer.com\/woocommerce-add-need-spend-x-get-free-shipping-cart-page\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"Paste the following code in functions.php: \/* Display remaining amount for free shipping in cart *\/ add_action( 'woocommerce_before_cart', 'bbloomer_free_shipping_cart_notice' ); [...]","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[52,371,327],"class_list":["post-54981","post","type-post","status-publish","format-standard","hentry","category-woocommerce","tag-cart","tag-free-shipping","tag-woocommerce"],"_links":{"self":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/54981","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=54981"}],"version-history":[{"count":2,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/54981\/revisions"}],"predecessor-version":[{"id":54983,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/54981\/revisions\/54983"}],"wp:attachment":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/media?parent=54981"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/categories?post=54981"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/tags?post=54981"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}