changing price range to from $$
-
okay this is driving me crazy, and could use a little help. Through tons of searching i was able to find the code to edit this and display our price range as a from $$ instead of the full price range – the full code is below. I did modify it to work for a variable subscription product and it did what i wanted it to do with one HUGE exception: When it displays From: $$$, the purchase options drop down, add to cart, and all info below that disappear from the product page. it seems this line of code is to blame – add_filter( ‘woocommerce_subscriptions_product_price_string’, ‘wc_ninja_custom_variable_price’, 10, 2 );
every time i edit this slightly we get back the purchase options but the price text goes back to ‘from $$ per month for 12 months” – full code below…any chance someone can help me with this?add_filter( ‘woocommerce_subscription_price_string’, ‘wc_ninja_custom_variable_price’, 10, 2 );
add_filter( ‘woocommerce_subscriptions_product_price_string’, ‘wc_ninja_custom_variable_price’, 10, 2 );function wc_ninja_custom_variable_price( $price, $product ) {
// Main Price
$prices = array( $product->get_variation_price( ‘min’, true ), $product->get_variation_price( ‘max’, true ) );
$price = $prices[0] !== $prices[1] ? sprintf( __( ‘From: %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( __( ‘From: %1$s’, ‘woocommerce’ ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );if ( $price !== $saleprice ) {
$price = ” . $saleprice . ‘ ‘ . $price . ”;
}return $price;
}
- The topic ‘changing price range to from $$’ is closed to new replies.