{"id":54465,"date":"2017-08-28T19:33:45","date_gmt":"2017-08-28T22:33:45","guid":{"rendered":"https:\/\/wiki.samuelchopard.ch\/?p=54465"},"modified":"2019-03-18T14:29:19","modified_gmt":"2019-03-18T13:29:19","slug":"disable-woocommerce-variable-product-price-and-use-the-min-price-instead","status":"publish","type":"post","link":"https:\/\/samuelchopard.ch\/wiki\/library\/disable-woocommerce-variable-product-price-and-use-the-min-price-instead\/","title":{"rendered":"Disable WooCommerce variable product price ($$$-$$$) and use the min price instead"},"content":{"rendered":"<p><!--more--><\/p>\n<p>Paste this code in your theme&#8217;s <em>functions.php<\/em>:<\/p>\n<pre class=\"EnlighterJSRAW\">\/**\n * @snippet       Disable Variable Product Price Range\n * @how-to        Watch tutorial @ https:\/\/businessbloomer.com\/?p=19055\n * @sourcecode    https:\/\/businessbloomer.com\/disable-variable-product-price-range-woocommerce\/\n * @author        Rodolfo Melogli\n * @compatible    WooCommerce 3.1.1\n *\/\n \nadd_filter( 'woocommerce_variable_price_html', 'bbloomer_variation_price_format_310', 10, 2 );\n \nfunction bbloomer_variation_price_format_310( $price, $product ) {\n \n\/\/ 1. Find the minimum regular and sale prices\n \n$min_var_reg_price = $product-&gt;get_variation_regular_price( 'min', true );\n$min_var_sale_price = $product-&gt;get_variation_sale_price( 'min', true );\n \n\/\/ 2. New $price\n \nif ( $min_var_sale_price ) {\n$price = sprintf( __( 'From: &lt;del&gt;%1$s&lt;\/del&gt;&lt;ins&gt;%2$s&lt;\/ins&gt;', 'woocommerce' ), wc_price( $min_var_reg_price ), wc_price( $min_var_sale_price ) );\n} else {\n$price = sprintf( __( 'From: %1$s', 'woocommerce' ), wc_price( $min_var_reg_price ) );\n}\n \n\/\/ 3. Return edited $price\n \nreturn $price;\n}<\/pre>\n<p><strong>Note:<\/strong> you can replace the &#8220;from:&#8221; text.<\/p>\n<p>&nbsp;<\/p>\n<p>Source:\u00a0<a target=\"_blank\" href=\"https:\/\/businessbloomer.com\/disable-variable-product-price-range-woocommerce\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/businessbloomer.com\/disable-variable-product-price-range-woocommerce\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"Paste this code in your theme's functions.php: \/** * @snippet Disable Variable Product Price Range * @how-to Watch tutorial @ [...]","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4,8],"tags":[180,228,318],"class_list":["post-54465","post","type-post","status-publish","format-standard","hentry","category-php-tricks","category-plugins","category-woocommerce","tag-min-price","tag-price","tag-variable"],"_links":{"self":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/54465","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=54465"}],"version-history":[{"count":1,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/54465\/revisions"}],"predecessor-version":[{"id":54861,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/54465\/revisions\/54861"}],"wp:attachment":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/media?parent=54465"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/categories?post=54465"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/tags?post=54465"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}