Home Forums Pinnacle Theme Variation Pricing Format

This topic is: resolved
Resolved
Posted in: Pinnacle Theme  
  • December 4, 2017 at 6:01 am #170604

    I have products with multiple pricing variations. I didn’t like that the full range of prices showed, so I changed it to show only the lowest price with “From” in front of it using a plugin called My Custom Functions which helped me to add some info to the php file without touching it. Everything worked great for a while. Initially all my products were on sale and the regular price was crossed off with the sale price showing the lowest price. But now that I’ve removed the sale price, I’ve still got the regular price crossed off, and I need to fix that. I’m wondering if there’s a small tweak I can make to the code below to fix it, or do I need to shut this off and revert back to showing the full pricing variation?

    This page is an example: https://rogueauroraphotography.com/wall-art-shop/timpanogos-farm/

    This is the php code that was copied in:

    /*
    Disable Variable Product Price Range:
    */

    add_filter( ‘woocommerce_variable_sale_price_html’, ‘my_variation_price_format’, 10, 2 );

    add_filter( ‘woocommerce_variable_price_html’, ‘my_variation_price_format’, 10, 2 );

    function my_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( __( ‘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( __( ‘%1$s’, ‘woocommerce’ ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );

    if ( $price !== $saleprice ) {
    $price = ‘‘ . $saleprice . ‘ ‘ . $price . ‘‘;
    }
    return $price;
    }

    Sorry, this forum is for Premium customers only. Please Login to continue

    If you are using a free theme you can access support on wordpress.org by searching for the free theme and using the support tab.