-
AuthorPosts
-
June 11, 2014 at 8:54 pm #277696
I need to be able to just show the lower price rather than a price range on single product page (http://firemagicgrillsandparts.com/product/36-portable-aog-grill) I found a code to completely hide it but not one for just hiding the higher price. Thanks in advanced.
Carla
June 11, 2014 at 9:29 pm #277710Also need to have the shop page and any subcategory page just show the lower number not a range.
June 12, 2014 at 3:12 pm #278076I was able to find the answer and fix the problem for now. For anyone who doesn’t like the current “From Price Range” on Woocommerce, here is a fix but remember if you upgrade the plugin the code will disappear and you will need to fix it again. This code is for when you are using variations. The lowest price will show. Instead of saying “From $1-$10”, it will now show $1.00. This code also changes the shop overview page so the lowest price will show.
Put the following code in your functions.php page of your theme.
// Use WC 2.0 variable price format, now include sale price strikeout
add_filter( ‘woocommerce_variable_sale_price_html’, ‘wc_wc20_variation_price_format’, 10, 2 );
add_filter( ‘woocommerce_variable_price_html’, ‘wc_wc20_variation_price_format’, 10, 2 );
function wc_wc20_variation_price_format( $price, $product ) {
// Main Price
$prices = array( $product->get_variation_price( ‘min’, true ), $product->get_variation_price( ‘max’, true ) );
$price = $prices[0] !== $prices[1] ? sprintf( __( ‘ %1$s’, ‘woocommerce’ ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
// Sale Price
$prices = array( $product->get_variation_regular_price( ‘min’, true ), $product->get_variation_regular_price( ‘max’, true ) );
sort( $prices );
$saleprice = $prices[0] !== $prices[1] ? sprintf( __( ‘ %1$s’, ‘woocommerce’ ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );if ( $price !== $saleprice ) {
$price = ‘‘ . $saleprice . ‘<ins>’ . $price . ‘</ins>’;
}
return $price;
}June 12, 2014 at 3:33 pm #278082Hey!
You can place the code into the child theme functions.php file – then it should be update save because theme and plugin updates won’t overwrite it.
Cheers!
PeterAugust 26, 2014 at 9:55 pm #309547Hi Dude!
I have a question about this trick: how can I show the suffix for taxes after the shown price?
I’d like to have a sort of “xx,yy$ VAT incl.”
Many thanks for your reply in advance.August 28, 2014 at 4:07 am #310175Hi!
The best place to ask would be the WooCommerce forums as they are more familiar with the exact filters/hooks to use.
Cheers!
Devin -
AuthorPosts
- You must be logged in to reply to this topic.