• Resolved vgnavada

    (@vgnavada)


    Hello,

    I wanted to HIDE the Variation Price Range & Show only the Price of the Default / Selected variant.

    I also don’t want the prices to be displayed 2 times on the Variable Product Page.
    [Screenshot: https://prnt.sc/yjt95j%5D)

    How to replace Variation Price Range with Selected Variant Price inside the Product page?

    I also tried the 2 snippets in the below post:
    https://learnwoo.com/hide-price-range-woocommerce-variable-products/

    Issues I faced are:
    1. It is hiding the variation price throughout the site including the sidebars & footer widgets where I’m using RELATED PRODUCTS, RECENTLY VIEWED PRODUCTS widgets.
    2. If the variation prices of 2 variants are the same (For Ex. Same product price but different colors), Then it is not showing the price at all.

    Can someone please help me?

    • This topic was modified 3 years, 9 months ago by vgnavada.

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello @vgnavada ,

    This seems to be an interesting challenge.

    I have taken help from this blog post and modified it so that the changes only works for the single product page. Here is the code that is working for me –

    function wc_varb_price_range( $wcv_price, $product ) {
    
    	
    		$prefix = sprintf('%s: ', __('From', 'wcvp_range'));
    		
    		$wcv_reg_min_price = $product->get_variation_regular_price( 'min', true );
    		$wcv_min_sale_price    = $product->get_variation_sale_price( 'min', true );
    		$wcv_max_price = $product->get_variation_price( 'max', true );
    		$wcv_min_price = $product->get_variation_price( 'min', true );
    		
    		$wcv_price = ( $wcv_min_sale_price == $wcv_reg_min_price ) ?
    		    wc_price( $wcv_reg_min_price ) :
    		    '<del>' . wc_price( $wcv_reg_min_price ) . '</del>' . '<ins>' . wc_price( $wcv_min_sale_price ) . '</ins>';
    
        if (is_product()) {
    		return ( $wcv_min_price == $wcv_max_price ) ?
    		    $wcv_price :
    		    sprintf('%s%s', $prefix, $wcv_price);
    	} else {
    		return $price = wc_format_price_range( $wcv_min_price, $wcv_max_price );
    	}
        
    }
     
    add_filter( 'woocommerce_variable_sale_price_html', 'wc_varb_price_range', 10, 2 );
    add_filter( 'woocommerce_variable_price_html', 'wc_varb_price_range', 10, 2 );

    I hope the information helps.

    Thank you ??

    Hi there,

    We’ve not heard back from you in a while, so I’m marking this thread as resolved.

    Hopefully, you were able to find a solution to your problem! If you have further questions, please feel free to open a new topic.

    Thank you ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How To Replace Variation Price Range with Selected Variant Price inside Product?’ is closed to new replies.