Tagged: price span, woocommerce product
-
AuthorPosts
-
November 3, 2025 at 12:05 pm #1490882
Hi
I have a variable product (see below) on my site but the price span is not showing up.
I disabled all plugins to check but that didn’t change anything.
Added this code:
#top .price span {
display: inline !important;
}
but same result. Only the first price is there.
Can you see what’s wrong?
thanks
NancyNovember 4, 2025 at 9:15 pm #1490956November 6, 2025 at 2:26 pm #1491005It’s the price span that’s not showing up.
Under the Gavekort: Familiefoto title it should give the price span for the varaints:
1.250 – 2.950 kr.November 9, 2025 at 2:02 pm #1491068November 10, 2025 at 9:57 am #1491100yes thanks
November 12, 2025 at 5:10 am #1491221Hi,
Thank you for the info.
We added the following code to the functions.php file to replace the base price with the variable price — it should also update based on the selected variation.
add_action( 'wp', function() { if ( is_product() ) { $product = wc_get_product( get_the_ID() ); if ( $product && $product->is_type( 'variable' ) ) { remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); add_action( 'woocommerce_single_product_summary', 'ava_woocommerce_single_product_summary_mod', 10 ); } } }); function ava_woocommerce_single_product_summary_mod() { $product = wc_get_product( get_the_ID() ); if ( ! $product || ! $product->is_type( 'variable' ) ) return; echo ' <div class="av-variable-price">'; echo $product->get_price_html(); echo '</div> '; } add_action( 'wp_footer', function() { if ( is_product() ) : ?> <script type="text/javascript"> jQuery(function($){ $('.variations_form').on('show_variation', function(event, variation){ $('.av-variable-price').html(variation.price_html); }); $('.variations_form').on('reset_data', function(){ var productMinMaxPrice = $('.variations_form').data('product_variations')[0].display_price_html; $('.av-variable-price').html(productMinMaxPrice); }); }); </script> <?php endif; });Best regards,
IsmaelNovember 12, 2025 at 10:41 am #1491232Thanks that is ok but the default is supposed to show the range of prices for variations –
Under the Gavekort: Familiefoto title it should give the price span for the varaints:
1.250 – 2.950 kr.
like this: https://imgur.com/xvAALb1
I have checked all the settings and can’t see what is wrong.
any ideas?November 13, 2025 at 5:15 am #1491275Hi,
We have adjusted the code a bit. You may notice a short delay before the price range displays because we needed to override the default variation switching behavior. Once the page is fully loaded, the price range should display correctly and selecting variations will switch the price as normal.
add_action( 'wp', function() { if ( is_product() ) { $product = wc_get_product( get_the_ID() ); if ( $product && $product->is_type( 'variable' ) ) { remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); add_action( 'woocommerce_single_product_summary', 'ava_woocommerce_single_product_summary_mod', 10 ); } } }); function ava_woocommerce_single_product_summary_mod() { $product = wc_get_product( get_the_ID() ); if ( ! $product || ! $product->is_type( 'variable' ) ) return; $min_price = $product->get_variation_price( 'min', true ); $max_price = $product->get_variation_price( 'max', true ); if ( $min_price !== $max_price ) { $price_html = wc_price( $min_price ) . ' - ' . wc_price( $max_price ); } else { $price_html = wc_price( $min_price ); } echo ' <div class="av-variable-price" style="opacity:0; transition: opacity 0.5s;"><span class="price"><span class="woocommerce-Price-amount amount"><bdi>' . $price_html . '</bdi></span></span></div> '; } add_action( 'wp_footer', function() { if ( is_product() ) : ?> <script type="text/javascript"> jQuery(function($){ var $priceContainer = $('.av-variable-price'); function formatPrice(price){ return price.toLocaleString('da-DK', { minimumFractionDigits: 0, maximumFractionDigits: 0 }) + ' kr.'; } function updatePrice(min, max){ var html = ''; if (min != max){ html = '<span class="price"><span class="woocommerce-Price-amount amount"><bdi>' + formatPrice(min) + ' - ' + formatPrice(max) + '</bdi></span></span>'; } else { html = '<span class="price"><span class="woocommerce-Price-amount amount"><bdi>' + formatPrice(min) + '</bdi></span></span>'; } $priceContainer.html(html).css('opacity', 1); } $(window).on('load', function(){ setTimeout(function(){ var productMin = <?php echo wc_get_price_to_display( wc_get_product(get_the_ID()), array('price'=>wc_get_product(get_the_ID())->get_variation_price('min', true)) ); ?>; var productMax = <?php echo wc_get_price_to_display( wc_get_product(get_the_ID()), array('price'=>wc_get_product(get_the_ID())->get_variation_price('max', true)) ); ?>; updatePrice(productMin, productMax); }, 1000); }); $('.variations_form').on('show_variation', function(event, variation){ $priceContainer.css('opacity', 0); setTimeout(function(){ $priceContainer.html(variation.price_html).css('opacity', 1); }, 100); }); }); </script> <?php endif; });Screenshot:
Best regards,
IsmaelNovember 15, 2025 at 1:24 pm #1491358can it just be with a static price range under the title?
it doesn’t need to change when the pakke is selected since the price changes below the description.thanks
NancyNovember 17, 2025 at 5:38 am #1491384Hi,
can it just be with a static price range under the title?
That should be possible — simply remove this block of code from the functions.php file:
$('.variations_form').on('show_variation', function(event, variation){ $priceContainer.css('opacity', 0); setTimeout(function(){ $priceContainer.html(variation.price_html).css('opacity', 1); }, 100); });Best regards,
IsmaelNovember 17, 2025 at 11:52 am #1491400This reply has been marked as private.November 17, 2025 at 4:44 pm #1491414Hi,
Thanks for the update, we’ll close this thread for now then. Please open a new thread if you should have any further questions or problems.
Best regards,
Rikard -
AuthorPosts
- The topic ‘price span not showing’ is closed to new replies.



