WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
[resolved] Tweak price display on page (5 posts)

  1. eventkonsulterna
    Member
    Posted 5 months ago #

    Hi guys!
    I just updated to the latest woocommerce version and now all products show the lowest to highest price (variable products) on the product page and in category list.

    Before it only showed the lowest price like I wanted it to.
    Can anyone help to get it back that way?

    This line that makes it: woocommerce/templates/single-product/price.php
    <p class="price"><?php echo $product->get_price_html(); ?></p>

    That now looks like [low] - [high] and I want it to just show the low price. Thank you

    https://wordpress.org/plugins/woocommerce/

  2. Feddman
    Member
    Posted 5 months ago #

    I have the same issue. For the time being, I've made a little css tweak to get things back to how it previously showed.

    .price .amount:nth-of-type(2) {
      display: none;
    }
    
    .price {
      color: rgba(0,0,0,0.0);
    }

    First block selects the second amount span (which is the one with highest price value and displays it to none

    Second block just makes the little dash in between transparent, so it doesn't show. (haven't come up with a more clever solution to hide text which is not in between tags just yet...)

    It might be a bit of a dirty solution, but works for the time being. I sure hope someone comes up with a more elegant solution...

  3. AncaIO
    Member
    Posted 5 months ago #

    Hi there.

    There are two snippets you can start from here, depending on whether you have sale prices or just regulars (untested): https://gist.github.com/angryoaf/5380297

    For regular price variations, I use this and it worked great for me:

    add_filter('woocommerce_variable_price_html', 'custom_variation_price', 10, 2);
    
    function custom_variation_price( $price, $product ) {
    
    	$price = '';
    
    	if ( !$product->min_variation_price || $product->min_variation_price !== $product->max_variation_price ) {
    		$price .= '<span class="from">' . _x('From', 'min_price', 'woocommerce') . ' </span>';
    		$price .= woocommerce_price($product->get_price());
    	}
    
    	return $price;
    }

    Let me know if it worked for you or if you require further assistance with this.

  4. Coen Jacobs
    Member
    Plugin Author

    Posted 5 months ago #

    We have added a workaround for this to our list of common issues (with a similar script as posted above): Revert variation price ranges back to the WooCommerce 2.0 format.

  5. eventkonsulterna
    Member
    Posted 5 months ago #

    The workaround works great! Thank you all for your fast help!

Reply

You must log in to post.

About this Plugin

About this Topic