Categories

Featured templates

WooCommerce. How to remove variable products available price range

Elina Webb June 2, 2016
Rating: 4.6/5. From 5 votes.
Please wait...

This video tutorial is going to show you how to remove variable products available price range in WooCommerce templates.

WooCommerce-How_to_remove_variable_products_available_price_range-1
  1. Connect to your FTP/File Manager, follow this path: wp-content/themes/themeXXXXX/includes and look for custom-function.php file to edit.

    WooCommerce-How_to_remove_variable_products_available_price_range-2

    You can also find this custom-function.php file under the Appearance > Editor in WordPress admin panel.

    WooCommerce-How_to_remove_variable_products_available_price_range-3
  2. In order to remove the larger value of the price, we should add the following code to custom-function.php – before the closing tag ?> to the bottom of the file:

    /*
    Disable Variable Product Price Range: 
    */
    
    add_filter( 'woocommerce_variable_sale_price_html', 'my_variation_price_format', 10, 2 );
    
    add_filter( 'woocommerce_variable_price_html', 'my_variation_price_format', 10, 2 );
    
    function my_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 . '</del> <ins>' . $price . '</ins>';
    }
    return $price;
    }

    Here is the result:

    WooCommerce-How_to_remove_variable_products_available_price_range-4
  3. To remove the price range completely, we will add the following code to the custom-function.php – before the closing tag ?> to the bottom of the file.

    /*
    Disable Variable Product Price Range completely:
    */
    
    add_filter( 'woocommerce_variable_sale_price_html', 'my_remove_variation_price', 10, 2 );
    add_filter( 'woocommerce_variable_price_html', 'my_remove_variation_price', 10, 2 );
    
    function my_remove_variation_price( $price ) {
    $price = '';
    return $price;
    }

    Below you can see the result of adding the code:

    WooCommerce-How_to_remove_variable_products_available_price_range-5

Feel free to check detailed video tutorial below.

WooCommerce. How to remove variable products available price range
Easy to Use Wordpress Themes
This entry was posted in WooCommerce Tutorials and tagged price range, variable products, WooCommerce. Bookmark the permalink.

Submit a ticket

If you are still unable to find a sufficient tutorial regarding your issue please use the following link to submit a request to our technical support team. We'll provide you with our help and assistance within next 24 hours: Submit a ticket