Advertisement
lorro

WooCommerce - Hide variable max price

Aug 11th, 2015
920
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.72 KB | None | 0 0
  1. <?php
  2.   // credit: http://snippet.fm/snippets/hide-max-price-for-variable-products-in-woocommerce/
  3.   add_filter( 'woocommerce_variable_sale_price_html', 'hide_variable_max_price', PHP_INT_MAX, 2 );
  4.   add_filter( 'woocommerce_variable_price_html',      'hide_variable_max_price', PHP_INT_MAX, 2 );
  5.   function hide_variable_max_price( $price, $_product ) {
  6.     $min_price_regular = $_product->get_variation_regular_price( 'min', true );
  7.     $min_price_sale    = $_product->get_variation_sale_price( 'min', true );
  8.     return ( $min_price_sale == $min_price_regular ) ?
  9.       'From '. wc_price( $min_price_regular ) :
  10.       '<del>' . wc_price( $min_price_regular ) . '</del>' . '<ins>From ' . wc_price( $min_price_sale ) . '</ins>';
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement