• hello,

    As per my clients requirement, it is needed to hide the variation price range. That is done and single price of the variable product is replaced with it. But when offer is given it gives error in display. Please refer the link provided for clead under standing. The sale price is set only for Bungundy color. Not for any other.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Ash

    (@ash222)

    hello,
    the code that i have used to hide the variation price range is
    add_filter( ‘woocommerce_variable_sale_price_html’, ‘detect_variation_price_format’, 10, 2 );
    add_filter( ‘woocommerce_variable_price_html’, ‘detect_variation_price_format’, 10, 2 );

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

    if ( $price !== $saleprice ) {
    $price = ‘<span style=”text-decoration: line-through;”>’ . $saleprice . ‘</span> ‘ . $price . ‘‘;
    }

    remove_action( ‘woocommerce_single_variation’, ‘woocommerce_single_variation’, 10 );
    add_action( ‘woocommerce_before_variations_form’, ‘woocommerce_single_variation’, 10 );

    return $price;
    }

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Moved to Fixing WordPress, this is not a Developing with WordPress topic.

    Please use the Woocommerce forums for plugin specific topics.

    https://www.ads-software.com/support/plugin/woocommerce/#new-post

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to hide the discount price tag’ is closed to new replies.