Show only lowest price for variation / or selected
-
Hi all,
I need help, I don’t find any way to dot what I want.
I have some variation products with different price. By default, woocommerce display lowest and highest price in the shop and product page.
I would like to :
– Have only the lowest price on shop page
– Have only the lowest price (by default) on product page or price of selected variation, if selected.Actually, I put this code in my function.php :
// Show only lowest prices in WooCommerce variable products add_filter( 'woocommerce_variable_sale_price_html', 'wpglorify_variation_price_format', 10, 2 ); add_filter( 'woocommerce_variable_price_html', 'wpglorify_variation_price_format', 10, 2 ); function wpglorify_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 = '<del>' . $saleprice . $product->get_price_suffix() . '</del> <ins>' . $price . $product->get_price_suffix() . '</ins>'; } return $price; }But as you can see on this screenshot, it display the lowest price and the selected item price.
Any idea to have only the selected item price displayed ?Thank you very very much !
The page I need help with: [log in to see the link]
The topic ‘Show only lowest price for variation / or selected’ is closed to new replies.