• Resolved kouzo

    (@kouzo)


    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 ?

    https://ibb.co/Y29NT1L

    Thank you very very much !

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Riaan K.

    (@riaanknoetze)

    Hi there,

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Hi!
    We’ve not heard back from you in a while, so I’m marking this thread as resolved. Hopefully, you were able to find a solution to your problem! If you have further questions, please feel free to open a new topic.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Show only lowest price for variation / or selected’ is closed to new replies.