Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #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

    #277710

    Also need to have the shop page and any subcategory page just show the lower number not a range.

    #278076

    I 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;
    }

    #278082

    Hey!

    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!
    Peter

    #309547

    Hi 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.

    #310175

    Hi!

    The best place to ask would be the WooCommerce forums as they are more familiar with the exact filters/hooks to use.

    Cheers!
    Devin

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.