{"id":6282,"date":"2016-08-21T13:10:19","date_gmt":"2016-08-21T17:10:19","guid":{"rendered":"https:\/\/themespress.ca\/?p=6282"},"modified":"2022-09-08T18:42:08","modified_gmt":"2022-09-08T22:42:08","slug":"free-shipping-woocommerce","status":"publish","type":"post","link":"https:\/\/themespress.ca\/en\/free-shipping-woocommerce\/","title":{"rendered":"Free Shipping for WooCommerce"},"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>There are different ways to configure free shipping for specific WooCommerce produits. We recommend using a filter that will assign free shipping to WooCommerce via their IDs.<\/p>\n<p>We will use the <strong><a href=\"http:\/\/hookr.io\/filters\/woocommerce_shipping_free_shipping_is_available\/\" target=\"_blank\" rel=\"noopener\">woocommerce_shipping_free_shipping_is_available<\/a><\/strong> function with ours.<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<h2 style=\"text-align: left\" class=\"vc_custom_heading vc_do_custom_heading\" >Free Shipping for WooCommerce Products<\/h2><div id=\"ts-enlighterjs-container-7490467\" 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-7490467\" 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=\"\">\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\/\/ Forcer la livraison gratuite \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\/\/\/\/\/\/\/\/\/\/\/\/\/  \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\n\nfunction templify_free_shipping( $is_available ) {\n\tglobal $woocommerce;\n \n\t\/\/ set the product ids that are eligible\n\t$eligible = array( &#039;5429&#039;, &#039;5425&#039;, &#039;5282&#039; );\n \n\t\/\/ get cart contents\n\t$cart_items = $woocommerce-&gt;cart-&gt;get_cart();\n\t\/\/ loop through the items looking for one in the eligible array\n\tforeach ( $cart_items as $key =&gt; $item ) {\n\t\tif( in_array( $item[&#039;product_id&#039;], $eligible ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n \n\t\/\/ nothing found return the default value\n\treturn $is_available;\n}\nadd_filter( &#039;woocommerce_shipping_free_shipping_is_available&#039;, &#039;templify_free_shipping&#039;, 20 );<\/pre><\/div>\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>You can see this row in the table: <strong>&#8216;5429&#8217;, &#8216;5425&#8217;, &#8216;5282&#8217;<\/strong>. These are the product IDs I wish to assign free shipping to. You can replace them with your own IDs and remember to use a comma between each of them.<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<\/div><\/div><\/div><\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"There are different ways to configure free shipping for specific WooCommerce produits. We recommend using a filter that will assign free shipping to WooCommerce via their IDs. We will use<div class=\"read-more\"><a class=\"btn button-secondary\" href=\"https:\/\/themespress.ca\/en\/free-shipping-woocommerce\/\">Read More<\/a><\/div>","protected":false},"author":81,"featured_media":4539,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[283],"tags":[318,328],"class_list":["post-6282","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-functions","tag-woocommerce-config"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/6282","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=6282"}],"version-history":[{"count":0,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/6282\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media\/4539"}],"wp:attachment":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media?parent=6282"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/categories?post=6282"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/tags?post=6282"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}