-
-
Save BFTrick/7643587 to your computer and use it in GitHub Desktop.
<?php | |
/** | |
* Plugin Name: WooCommerce Remove Variation "From: $XX" Price | |
* Plugin URI: https://gist.github.com/BFTrick/7643587 | |
* Description: Disable the WooCommerce variable product "From: $X" price. | |
* Author: Patrick Rauland | |
* Author URI: http://patrickrauland.com/ | |
* Version: 1.0 | |
* | |
* This program is free software: you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation, either version 3 of the License, or | |
* (at your option) any later version. | |
* | |
* This program is distributed in the hope that it will be useful, | |
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
* GNU General Public License for more details. | |
* | |
* You should have received a copy of the GNU General Public License | |
* along with this program. If not, see <http://www.gnu.org/licenses/>. | |
* | |
* @author Patrick Rauland | |
* @since 1.0 | |
*/ | |
function patricks_custom_variation_price( $price, $product ) { | |
$target_product_types = array( | |
'variable' | |
); | |
if ( in_array ( $product->product_type, $target_product_types ) ) { | |
// if variable product return and empty string | |
return ''; | |
} | |
// return normal price | |
return $price; | |
} | |
add_filter('woocommerce_get_price_html', 'patricks_custom_variation_price', 10, 2); | |
// that's all folks! |
Queenb123 and for other woocommerce 2.2+ users,
Instead of showing up like "$1 - $10", it'll show up these steps will make it show up as "$1"
- go to the wordpress administration panel
- Click on Plugins
- Click Editor
- Select plugin to edit : WooCommerce
- You can just copy and paste the code on the bottom
function spoofee_custom_variation_price( $price, $product ) {
$target_product_types = array('variable');
if ( in_array ( $product->product_type, $target_product_types ) ) {
return '$'.$product->min_variation_price;
}
return $price;
}
add_filter('woocommerce_get_price_html', 'spoofee_custom_variation_price', 10, 2);
Do not do what @kenji4861 says. He is doing it the wrong way. @BFTrick provided a plugin. If you do not know how to use the code, it is better to get a dev to implement it for you.
Hi there, PLEASE Help me out, i used kenji4861 his way to add custom code. and now my site is not working...
How can i solve this issue? Please let me know?
Quick response would be appreciated as i am in hurry!
Holy sh*t, it works great... as a plugin!
@Bilal951 if you need help still, let me know and I can fix it for you.
Instead of creating a plugin, you can also add it in your functions.
@BFTrick
Nice. Thank you for the code.
What would the code be if I wanted to only show the maximum price? Thanks!
Hi :-) Thanks for the script, it will help me this is exactly what I need :-) . But I don't know where to place it : in my Child Theme or in Woo ?
Thanks a lot.
You Are a genius man...
Where is the plugin?
Hi, how can I show the max price instead of the lowest price?
so sorry to ask, im new at this where exactly am i supposed to add this pls?