• Hi,

    I would like to remove variable product for range price regarding variable products.

    When ELEX WooCommerce Product Price Custom Text (Before & After Text) and Discount the following from functions.php is workable however as soon as activate the plugin the price range is shown altought I would like a From price : A partir de 33,35€ HT

    //  PAGES PRODUIT : Afficher un prix ? A partir de ? pour les produits variables
    
    /* Afficher "à partir de" pour les produits variables */
    add_filter( 'woocommerce_variable_sale_price_html', 'wpm_variation_price_format', 10, 2 );
    add_filter( 'woocommerce_variable_price_html', 'wpm_variation_price_format', 10, 2 );
    
    function wpm_variation_price_format( $price, $product ) {
    	//On récupère le prix min et max du produit variable
    	$min_price = $product->get_variation_price( 'min', true );
    	$max_price = $product->get_variation_price( 'max', true );
    
    	// Si les prix sont différents on affiche "à partir de ..."
    	if ($min_price != $max_price){
    		$price = sprintf( __( 'A partir de %1$s', 'woocommerce' ), wc_price( $min_price ) );
    		return $price;
    	// Sinon on affiche juste le prix
    	} else {
    		$price = sprintf( __( '%1$s', 'woocommerce' ), wc_price( $min_price ) );
    		return $price;
    	}
    }

    Any hook ?

    Regards,

    Emmanuel

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

Viewing 1 replies (of 1 total)
  • Plugin Author ELEXtensions

    (@elextensions)

    Hello @manux006,

    Please try this updated the code 
    
    add_filter( 'woocommerce_variable_sale_price_html', 'wpm_variation_price_format', 10, 2 );
    add_filter( 'woocommerce_variable_price_html', 'wpm_variation_price_format', 9999, 2 );
    
    function wpm_variation_price_format( $price, $product ) {
        //On récupère le prix min et max du produit variable
        $min_price = $product->get_variation_price( 'min', true );
        $max_price = $product->get_variation_price( 'max', true );
    
        // Si les prix sont différents on affiche "à partir de ..."
        if ($min_price != $max_price){
            $price = sprintf( __( 'A partir de %1$s', 'woocommerce' ), wc_price( $min_price ) );
            return $price;
        // Sinon on affiche juste le prix
        } else {
            $price = sprintf( __( '%1$s', 'woocommerce' ), wc_price( $min_price ) );
            return $price;
        }
    }

    Let us know your feedback.

    Thanks

Viewing 1 replies (of 1 total)
  • The topic ‘Remove range price for variable products’ is closed to new replies.