• 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;
    }

Viewing 1 replies (of 1 total)
  • It looks like the php in your function has errored at some point.

    Make sure all the apostrophes are straight ones, not smart ones. If posting code in the forum, use the code button or enclose it in back ticks. This will make sure quotes are not changed. You haven’t, and the editor shows only smart quotes, so I can’t tell if they were smart quotes or not to begin with.

    Validate your code here:
    https://phpcodechecker.com/

    Set: define('WP_DEBUG', true); in wp-config.php. Get the page to crash, then inspect the markup for a notice, warning or error. This may give a clue.

Viewing 1 replies (of 1 total)
  • The topic ‘changing price range to from $$’ is closed to new replies.