Disable Variable Product Price Range php

You are here:
< Back

/**
* @snippet Disable Variable Product Price Range
* @how-to Watch tutorial @ https://businessbloomer.com/?p=19055
* @sourcecode https://businessbloomer.com/disable-variable-product-price-range-woocommerce/
* @author Rodolfo Melogli
* @compatible WooCommerce 2.4.7
*/

add_filter( ‘woocommerce_variable_sale_price_html’, ‘bbloomer_variation_price_format’, 10, 2 );
add_filter( ‘woocommerce_variable_price_html’, ‘bbloomer_variation_price_format’, 10, 2 );

function bbloomer_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 . $product->get_price_suffix() . ‘</del> <ins>’ . $price . $product->get_price_suffix() . ‘</ins>’;
}
return $price;
}

zeilermedia logo

Get $20 USD of store credit PLUS 20% off your first license when you register for a free account

Claim Now

 

 

Dismiss

TOP
0

Your Cart