Comments on: Change the price display on variable products https://www.cssigniter.com/change-the-price-display-on-variable-products/ Premium WordPress themes, templates & plugins Tue, 14 Nov 2023 16:18:54 +0000 hourly 1 https://wordpress.org/?v=6.4.2 By: Antonin https://www.cssigniter.com/change-the-price-display-on-variable-products/#comment-357982 Tue, 14 Nov 2023 16:18:54 +0000 https://www.cssigniter.com/?p=23185#comment-357982 In reply to Flaviu.

Hi Flaviu,

I’m really interested in your “translation compatible code” but it shuts down my whole website.
While Nik’s one is working fine (but without translation nor span abilities).
Could you please help me in that ?

Thanks a lot in advance,

]]>
By: Flaviu https://www.cssigniter.com/change-the-price-display-on-variable-products/#comment-354824 Wed, 14 Jun 2023 16:15:56 +0000 https://www.cssigniter.com/?p=23185#comment-354824 Hey Nik, I needed some css customization for frontend so I added a span and used woocommerce included translation From. So here is my version:

/*
* Change display price for variations
*
*/
add_filter( ‘woocommerce_get_price_html’, ‘fw_variable_price_format’, 10, 2 );
function fw_variable_price_format( $price, $product ) {
if($product->is_type(‘variable’)){
return ”._x(‘From:’, ‘min_price’, ‘woocommerce’).’ ‘.wc_price($product->get_variation_price( ‘min’, true ));
}
return $price;
}

]]>
By: Fantou https://www.cssigniter.com/change-the-price-display-on-variable-products/#comment-354822 Wed, 14 Jun 2023 11:51:25 +0000 https://www.cssigniter.com/?p=23185#comment-354822 Hi,
Works perfectly for me, thanks for this! :)

]]>
By: Nik https://www.cssigniter.com/change-the-price-display-on-variable-products/#comment-348626 Tue, 20 Dec 2022 14:25:18 +0000 https://www.cssigniter.com/?p=23185#comment-348626 In reply to Michael.

Hello.
I’m not sure if this is something we can help with, however could you paste the entire error code in a gist so we can take a look?

]]>
By: Michael https://www.cssigniter.com/change-the-price-display-on-variable-products/#comment-348261 Wed, 07 Dec 2022 21:42:27 +0000 https://www.cssigniter.com/?p=23185#comment-348261 Hi, snipped worked just amazing, I tryed a couple of plugins that works fine but when I create an elementor template for single products the plugins didn’t work, thats when this code work cause it works with elementor, but since the last woocommerce I’m having an error every time I edit a variable product, this is the error that I received via email:

There is an error type E_ERROR in line 1876 from file /home/*****/public_html/wp-content/themes/rehub-theme/functions.php. Error Message: Uncaught Error: Call to a member function get_type() on null in /home/****/public_html/wp-content/themes/rehub-theme/functions.php:1876
Stack trace:
#0 /home/jmeeuxgf/public_html/wp-includes/class-wp-hook.php(308): cssigniter_change_variable_price_display(‘

]]>
By: Nik https://www.cssigniter.com/change-the-price-display-on-variable-products/#comment-345946 Tue, 04 Oct 2022 14:49:47 +0000 https://www.cssigniter.com/?p=23185#comment-345946 In reply to Emilia.

Hello.
I have modified the code a bit, now it should only affect the main price display below the title on variable products and not the variation price that appears after selecting the preferred product configuration from the drop downs. Give it a shot and let me know if it works for you.

]]>
By: Emilia https://www.cssigniter.com/change-the-price-display-on-variable-products/#comment-345141 Wed, 14 Sep 2022 07:48:36 +0000 https://www.cssigniter.com/?p=23185#comment-345141 It is overwriting the price and when I elect a specific size it still says from XXX instead of displaying the concrete size

I was thinking to add and if statement and checking if none of options is selected return overwritten price with from else return regular price .

But I don’t know how to write it
can you help

]]>
By: Nik https://www.cssigniter.com/change-the-price-display-on-variable-products/#comment-344725 Tue, 06 Sep 2022 09:24:23 +0000 https://www.cssigniter.com/?p=23185#comment-344725 In reply to Becks.

Hello.
I have just tested this locally and it appears to be working normally as seen here https://i.imgur.com/4u6g8HL.png
Could you please double check the code, or delete and re-paste it and see if anything changes?

]]>
By: Becks https://www.cssigniter.com/change-the-price-display-on-variable-products/#comment-344698 Mon, 05 Sep 2022 20:20:31 +0000 https://www.cssigniter.com/?p=23185#comment-344698 This is great – thank you. However when I actually choose my variation at the bottom of the page, just before adding to cart, it displays “From: $x” instead of the actual variation price. How do I fix this? Thanks!

]]>
By: Nik https://www.cssigniter.com/change-the-price-display-on-variable-products/#comment-342650 Thu, 28 Jul 2022 10:52:18 +0000 https://www.cssigniter.com/?p=23185#comment-342650 In reply to Tom.

Hello Tom.
Can you tell us what sort of error you are getting?

]]>