• Resolved nikosgkil

    (@nikosgkil)


    Hello!

    I am searching for 2 days now, maybe I am missing something.

    I want to hide price range for WooCommerce Variable Products from both shop page and product page for variable products.

    I found a snippet from learnwoo(.)com that hides the price range from shop page and when I first load a product page but when I click on a product variation, the price range appears again.

    I am using porto theme.

    The code I use is this:

    //Hide Price Range for WooCommerce Variable Products
    add_filter( 'woocommerce_variable_sale_price_html', 
    'lw_variable_product_price', 10, 2 );
    add_filter( 'woocommerce_variable_price_html', 
    'lw_variable_product_price', 10, 2 );
    
    function lw_variable_product_price( $v_price, $v_product ) {
    
    // Product Price
    $prod_prices = array( $v_product->get_variation_price( 'min', true ), 
                                $v_product->get_variation_price( 'max', true ) );
    $prod_price = $prod_prices[0]!==$prod_prices[1] ? sprintf(__('From: %1$s', 'woocommerce'), 
                           wc_price( $prod_prices[0] ) ) : wc_price( $prod_prices[0] );
    
    // Regular Price
    $regular_prices = array( $v_product->get_variation_regular_price( 'min', true ), 
                              $v_product->get_variation_regular_price( 'max', true ) );
    sort( $regular_prices );
    $regular_price = $regular_prices[0]!==$regular_prices[1] ? sprintf(__('From: %1$s','woocommerce')
                          , wc_price( $regular_prices[0] ) ) : wc_price( $regular_prices[0] );
    
    if ( $prod_price !== $regular_price ) {
    $prod_price = '<del>'.$regular_price.$v_product->get_price_suffix() . '</del> <ins>' . 
                           $prod_price . $v_product->get_price_suffix() . '</ins>';
    }
    return $prod_price;
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    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.

    If you do require more help with the actual coding, we’d recommend you hire a developer who can take a look at this, quote you for their services and help you add this feature to your site. We’d recommend getting in touch with a web developer or one of the customisation experts listed at https://woocommerce.com/customizations/.`

    Cheers.

    Thread Starter nikosgkil

    (@nikosgkil)

    Well, ok. Thanks for the chance.

    I hope that someone will jump in and give some guidance.

    Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    Hi @nikosgkil ??

    We’ve not seen any activity on this thread for 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.

    Cheers!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show only selected variation price and not range’ is closed to new replies.