Please submit a private ticket if you need to share sensitive information, such as license details and admin credentials.

Okay
  Public Ticket #3745099
Variations Radio Buttons does not show price on variation selected
Open

Comments

  • Lorenzo started the conversation

    Hi everyone, I purchased the plugin to have immediate support for the following problem: I am using the Variations Radio Buttons 3.5.8 plugin and I have set that the price is not shown unless the product variant is selected. (here is an example: --) This works perfectly if the product has more than one variant, but if the product only has 1 variant even by selecting the only variant not no price is visible (here is an example: --). How is this possible? Would it be possible to solve this problem and make everything work as it does on products with two or more variants? Thanks in advance!

    Attached files:  Screenshot 2024-10-15 alle 8.29.03 PM.png
      Screenshot 2024-10-15 alle 8.29.08 PM.png

  •  1,222
    Dustin replied

    Hi Lorenzo,

    This is the default behavior from WooCommerce. When having only one variation, the price was displayed on the main price, so it wasn't shown under variations anymore:

    4832187664.png

    Please add the custom code below to fix it. (How to add custom code? ↗):

    add_action( 'wp_footer', function () {
    	?>
        <script type="text/javascript">
          (function($) {
            $(document).on('found_variation', function(e, t) {
              if ($(e['target']).find('.single_variation .woocommerce-variation-price').text() === '') {
                $(e['target']).find('.single_variation .woocommerce-variation-price').
                    html($(e['target']).find('.woovr-variation-active').data('pricehtml'));
              }
            });
          })(jQuery);
        </script>
    	<?php
    }, 99 );

    Best regards,
    Dustin