{"id":5144,"date":"2017-09-29T12:08:33","date_gmt":"2017-09-29T16:08:33","guid":{"rendered":"https:\/\/themespress.ca\/?p=5144"},"modified":"2022-10-01T14:47:15","modified_gmt":"2022-10-01T18:47:15","slug":"woocommerce-adding-custom-content-in-your-cart-page","status":"publish","type":"post","link":"https:\/\/themespress.ca\/en\/woocommerce-adding-custom-content-in-your-cart-page\/","title":{"rendered":"Woocommerce: Adding Custom Content in your Cart Page"},"content":{"rendered":"<div class=\"wpb-content-wrapper\"><div class=\"vc_row wpb_row vc_row-fluid\"><div class=\"wpb_column vc_column_container vc_col-sm-12\"><div class=\"vc_column-inner\"><div class=\"wpb_wrapper\">\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>This tutorial will show you how to add custom content in your WooCommerce cart page with the help of specific hooks.<\/p>\n<p>To do this custom coding, we strongly recommend using a <strong>WordPress child them and Woocommerce (obviously)<\/strong>.<\/p>\n<p>Make sure to not forget to enable the child them via Appearance &#8211;&gt; Themes. It&#8217;s also vital to keep the parent theme.<\/p>\n<p><strong>Don&#8217;t forget to make a quick back up of your theme<\/strong> before making any changes.<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<h2 style=\"text-align: left\" class=\"vc_custom_heading vc_do_custom_heading\" >List of custom hooks.<\/h2>\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>\n1 \u2013 woocommerce_before_cart<br \/>\n2 \u2013 woocommerce_before_cart_table<br \/>\n3 \u2013 woocommerce_before_cart_table<br \/>\n4 \u2013 woocommerce_cart_contents<br \/>\n5 \u2013 woocommerce_after_cart_contents<br \/>\n6 \u2013 woocommerce_after_cart_table<br \/>\n7 \u2013 woocommerce_before_cart_totals<br \/>\n8 \u2013 woocommerce_cart_totals_before_shipping<br \/>\n9 \u2013 woocommerce_before_shipping_calculator<br \/>\n10 \u2013 woocommerce_after_shipping_calculator<br \/>\n11 \u2013 woocommerce_cart_totals_after_shipping<br \/>\n12 \u2013 woocommerce_cart_totals_before_order_total<br \/>\n13 \u2013 woocommerce_cart_totals_after_order_total<br \/>\n14 \u2013 woocommerce_proceed_to_checkout<br \/>\n15 \u2013 woocommerce_after_cart_totals<br \/>\n16 \u2013 woocommerce_after_cart<\/p>\n<p>By using the list of hooks above, here&#8217;s how you can add custom content to your cart page. For example, using the <strong>woocommerce_before_cart<\/strong> hook will display content just under the page&#8217;s title. Here&#8217;s how to insert it into your child theme.<\/p>\n<p>It&#8217;s very important to change the naming of each function.<\/p>\n<p>Here&#8217;s an example.<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<div id=\"ts-enlighterjs-container-2506940\" class=\"ts-enlighterjs-container-single-enabled  \" style=\"width: 100%;  margin-top: 0px; margin-bottom: 0px;\" data-enlighter-doubleclick=\"true\" data-enlighter-windowbutton=\"true\" data-enlighter-windowtext=\"New Window\" data-enlighter-rawbutton=\"true\" data-enlighter-rawtext=\"RAW Code\" data-enlighter-infobutton=\"false\" data-enlighter-infotext=\"EnlighterJS\" data-enlighter-indent=\"2\"><pre id=\"ts-enlighterjs-pre-2506940\" class=\"\" style=\"white-space: pre-wrap; height: 100%; margin: 0; padding: 0;\" data-enlighter-language=\"php\" data-enlighter-theme=\"enlighter\" data-enlighter-group=\"\" data-enlighter-title=\"\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"1\" data-enlighter-highlight=\"\">add_action(&#039;woocommerce_before_cart&#039;, &#039;nomdemafonction&#039;, 1);\nfunction nomdemafonction() {\n    echo &#039;Cher Clients&#039;; \n\techo &#039;Vous pouvez obtenir la livraison gratuite &agrave; partir de 50 $ d&rsquo;achat.&#039;; \n}<\/pre><\/div><h2 style=\"text-align: left\" class=\"vc_custom_heading vc_do_custom_heading\" >La liste des hooks par default<\/h2><div id=\"ts-enlighterjs-container-6482770\" class=\"ts-enlighterjs-container-single-enabled  \" style=\"width: 100%;  margin-top: 0px; margin-bottom: 0px;\" data-enlighter-doubleclick=\"true\" data-enlighter-windowbutton=\"true\" data-enlighter-windowtext=\"New Window\" data-enlighter-rawbutton=\"true\" data-enlighter-rawtext=\"RAW Code\" data-enlighter-infobutton=\"false\" data-enlighter-infotext=\"EnlighterJS\" data-enlighter-indent=\"2\"><pre id=\"ts-enlighterjs-pre-6482770\" class=\"\" style=\"white-space: pre-wrap; height: 100%; margin: 0; padding: 0;\" data-enlighter-language=\"php\" data-enlighter-theme=\"enlighter\" data-enlighter-group=\"\" data-enlighter-title=\"\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"1\" data-enlighter-highlight=\"\">\/\/ These are actions you can unhook\/remove!\n \nadd_action( &#039;wp_loaded&#039;, array( WC_Cart, &#039;init&#039; ) );\nadd_action( &#039;wp&#039;, array( WC_Cart, &#039;maybe_set_cart_cookies&#039; ), 99 );\nadd_action( &#039;shutdown&#039;, array( WC_Cart, &#039;maybe_set_cart_cookies&#039; ), 0 );\nadd_action( &#039;woocommerce_add_to_cart&#039;, array( WC_Cart, &#039;calculate_totals&#039; ), 20, 0 );\nadd_action( &#039;woocommerce_applied_coupon&#039;, array( WC_Cart, &#039;calculate_totals&#039; ), 20, 0 );\nadd_action( &#039;woocommerce_check_cart_items&#039;, array( WC_Cart, &#039;check_cart_items&#039; ), 1 );\nadd_action( &#039;woocommerce_check_cart_items&#039;, array( WC_Cart, &#039;check_cart_coupons&#039; ), 1 );\nadd_action( &#039;woocommerce_after_checkout_validation&#039;, array( WC_Cart, &#039;check_customer_coupons&#039; ), 1 );\n \nadd_action( &#039;woocommerce_cart_collaterals&#039;, &#039;woocommerce_cross_sell_display&#039; );\nadd_action( &#039;woocommerce_cart_collaterals&#039;, &#039;woocommerce_cart_totals&#039;, 10 );\nadd_action( &#039;woocommerce_proceed_to_checkout&#039;, &#039;woocommerce_button_proceed_to_checkout&#039;, 20 );<\/pre><\/div><\/div><\/div><\/div><\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"This tutorial will show you how to add custom content in your WooCommerce cart page with the help of specific hooks. To do this custom coding, we strongly recommend using<div class=\"read-more\"><a class=\"btn button-secondary\" href=\"https:\/\/themespress.ca\/en\/woocommerce-adding-custom-content-in-your-cart-page\/\">Read More<\/a><\/div>","protected":false},"author":81,"featured_media":5148,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[283],"tags":[313,328],"class_list":["post-5144","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-plugins","tag-woocommerce-config"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/5144","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/users\/81"}],"replies":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/comments?post=5144"}],"version-history":[{"count":0,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/5144\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media\/5148"}],"wp:attachment":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media?parent=5144"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/categories?post=5144"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/tags?post=5144"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}