s2prod

Disable variable product price range in WooCommerce

Feb 11th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.03 KB | None | 0 0
  1.  
  2. //At first, create a help.php in your Child-Theme folder
  3. //Add code at below in functions.php Child-Theme
  4.  
  5.  
  6. function wc_varb_price_range( $wcv_price, $product ) {
  7.  
  8.     $prefix = sprintf('%s: ', __('From', 'wcvp_range'));
  9.  
  10.     $wcv_reg_min_price = $product->get_variation_regular_price( 'min', true );
  11.     $wcv_min_sale_price    = $product->get_variation_sale_price( 'min', true );
  12.     $wcv_max_price = $product->get_variation_price( 'max', true );
  13.     $wcv_min_price = $product->get_variation_price( 'min', true );
  14.  
  15.     $wcv_price = ( $wcv_min_sale_price == $wcv_reg_min_price ) ?
  16.         wc_price( $wcv_reg_min_price ) :
  17.         '<del>' . wc_price( $wcv_reg_min_price ) . '</del>' . '<ins>' . wc_price( $wcv_min_sale_price ) . '</ins>';
  18.  
  19.     return ( $wcv_min_price == $wcv_max_price ) ?
  20.         $wcv_price :
  21.         sprintf('%s%s', $prefix, $wcv_price);
  22. }
  23.  
  24. add_filter( 'woocommerce_variable_sale_price_html', 'wc_varb_price_range', 10, 2 );
  25. add_filter( 'woocommerce_variable_price_html', 'wc_varb_price_range', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment