Title: Replace variable products price range
Last modified: October 19, 2021

---

# Replace variable products price range

 *  Resolved [carloz san](https://wordpress.org/support/users/wajaraja/)
 * (@wajaraja)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/replace-variable-products-price-range/)
 * I have 2 code snippets where ;
 * Code A has the following functions:
 *  Changed the price range to “from (harga terendah)+lowest price”
    Displaying 
   it on shop page Hidden it on single product page
 * This code works fine
 * Code B has the following functions:
 *  Change the price format to ;
    Thousands to ribu Million to juta Billion to M
 * This code works fine.
 * The problem is that when both codes are activated at the same time (I’m using
   code snippets), code A doesn’t work properly.
    The shop page which previously
   displayed “from+lowest price” now displays only the lowest price (with the price
   format from code B).
 * Please see the before and after display changes below :
 * Before using code A and code B > [See](http://prnt.sc/1wghm7q)
 * Using code A > [See](http://prnt.sc/1wghok7)
 * Adding code B > [See](http://prnt.sc/1wghp23)
 * I want > [See](http://prnt.sc/1wghrsq)
 * How do I get the two codes above to work properly when activated at the same 
   time?
 * Any help is greatly appreciated.
 * Code A :
 *     ```
       //Hide Price Range for WooCommerce Variable Products
           add_filter( 'woocommerce_variable_sale_price_html','lw_variable_product_price', 5, 2 );
           add_filter( 'woocommerce_variable_price_html','lw_variable_product_price', 5, 2 );
   
           function lw_variable_product_price( $price, $product ) {
           if(is_product()) {
           return $price;
           }
   
           // Product Price
           $prices = array( $product->get_variation_price( 'min', true ),
           $product->get_variation_price( 'max', true ) );
           $price = $prices[0]!==$prices[1] ? sprintf(__('Harga terendah : %1$s', 'woocommerce'),wc_price( $prices[0] ) ) : wc_price( $prices[0] );
   
            // Regular Price
           $regular_prices = array( $product->get_variation_regular_price( 'min', true ),
           $product->get_variation_regular_price( 'max', true ) );
           sort( $regular_prices );
           $regular_price = $regular_prices[0]!==$regular_prices[1] ? sprintf(__('Harga terendah : %1$s','woocommerce'), wc_price( $regular_prices[0] ) ) : wc_price( $regular_prices[0] );
   
           if ( $price !== $regular_price ) {
           $price = '<del>'.$regular_price.$product->get_price_html() . '</del> <ins>' .
           $price . $product->get_price_html() . '</ins>';
           }
           return $price;
           }
   
            //Hide “From:$X”
           add_filter('woocommerce_get_price_html', 'lw_hide_variation_price', 5, 2);
           function lw_hide_variation_price( $price, $product ) {
   
           $product_types = array( 'variable');
           if ( in_array ( $product->product_type, $product_types ) && !(is_shop()) ) {
           return '';
           }
           // return regular price
           return $price;
           }
   
       Code B : 
   
           add_filter( 'woocommerce_get_price_html','rei_woocommerce_price_html',5, 2 );
   
       	function rei_woocommerce_price_html( $price, $product ) {
   
   
           $currency = get_woocommerce_currency_symbol( );
           $price = $currency .' ' .custom_number_format( floatval( $product->get_price() ), 2 );
           return $price;
       	}
   
                $n = 1000000;
   
               function custom_number_format12222($n) {
   
                   $n = (0+str_replace("."," ",$n));
   
                   if(!is_numeric($n)) return false;
   
                   if($n>1000000000000) return round(($n/1000000000000),1).' '.'-T';
                   else if($n>1000000000) return round(($n/1000000000),2).' '.'M';
                   else if($n>1000000) return round(($n/1000000),3).' '.'juta';
                   else if($n>1000) return round(($n/1000),0).' '.'ribu';
   
                   return number_format($n);
   
               }
       ```
   

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

 *  [MayKato](https://wordpress.org/support/users/maykato/)
 * (@maykato)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/replace-variable-products-price-range/#post-14988562)
 * Hello,
 * 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](https://developer.woocommerce.com/)
   for resources on developing for WooCommerce.
 * You can also visit the [WooCommerce Facebook group](https://www.facebook.com/groups/advanced.woocommerce/)
   or the `#developers` channel of the [WooCommerce Community Slack](https://woocommerce.com/community-slack/).
 *  [MayKato](https://wordpress.org/support/users/maykato/)
 * (@maykato)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/replace-variable-products-price-range/#post-15019561)
 * This thread has been inactive for a while, so I’m going to mark this as resolved–
   if you have any further questions, you can start a new thread.

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

The topic ‘Replace variable products price range’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [price range](https://wordpress.org/support/topic-tag/price-range/)
 * [Shop page](https://wordpress.org/support/topic-tag/shop-page/)
 * [variable](https://wordpress.org/support/topic-tag/variable/)

 * 2 replies
 * 2 participants
 * Last reply from: [MayKato](https://wordpress.org/support/users/maykato/)
 * Last activity: [4 years, 7 months ago](https://wordpress.org/support/topic/replace-variable-products-price-range/#post-15019561)
 * Status: resolved