Comments 3Rudolf started the conversationApril 5, 2023 at 3:54pmHello,we have variations with different prices. Is there a way to update [wpcbm_save_percentage] or [wpcbm_save_amount] when selecting a variation?Thanks! 767Janilyn repliedApril 6, 2023 at 10:12amHi Rudolf, Thank you for contacting WPClever Support Forum. We’ve received your ticket and assigned one of our developers to help you with that. He’ll be looking into your question and responding with specific instructions as soon as possible. Please stay patient as we're having very heavy workloads, it might take some time for our developers to reach back. Best regards.Janilyn T. - WPClever Support Agent 1,222Dustin repliedApril 6, 2023 at 5:06pmHi Rudolf,Yes, you can do that!First, please update our plugin to the latest version 2.2.0.Then add the below custom code (How to add custom code?) add_action( 'wp_footer', function () { ?> <script type="text/javascript"> (function($) { $(document).on('found_variation', function(e, t) { var product_id = $(e['target']).attr('data-product_id'); if ($('.wpcbm-pid-' + product_id).length) { $('.wpcbm-pid-' + product_id).each(function() { if ($(this).hasClass('wpcbm-badge-3749')) { // badge 3749 have the shortcode [wpcbm_saved_percentage] var $this = $(this); if ($this.attr('data-ori-content') == undefined) { $this.attr('data-ori-content', $this.text()); } if (parseFloat(t['display_price']) < parseFloat(t['display_regular_price'])) { // calculate new saved percentage var percentage = Math.round( ((t['display_regular_price'] - t['display_price']) / t['display_regular_price']) * 100); $this.text('Saved ' + percentage + '%'); } else { $this.text($this.attr('data-ori-content')); } } }); } }); $(document).on('reset_data', function(e) { var product_id = $(e['target']).attr('data-product_id'); $('.wpcbm-pid-' + product_id).each(function() { if ($(this).hasClass('wpcbm-badge-3749')) { // badge 3749 have the shortcode [wpcbm_saved_percentage] $(this).text($(this).attr('data-ori-content')); } }); }); })(jQuery); </script> <?php }, 99 );And the result (screen record video) https://www.screencast.com/t/zW1IkU9aQrYou need to change the number '3749' in the above snippet to the badge ID on your site.Best regards,Dustin Sign in to reply ...
Hello,
we have variations with different prices. Is there a way to update [wpcbm_save_percentage] or [wpcbm_save_amount] when selecting a variation?
Thanks!
Hi Rudolf,
Thank you for contacting WPClever Support Forum.
We’ve received your ticket and assigned one of our developers to help you with that.
He’ll be looking into your question and responding with specific instructions as soon as possible.
Please stay patient as we're having very heavy workloads, it might take some time for our developers to reach back.
Best regards.
Janilyn T. - WPClever Support Agent
Hi Rudolf,
Yes, you can do that!
First, please update our plugin to the latest version 2.2.0.
Then add the below custom code (How to add custom code?)
And the result (screen record video) https://www.screencast.com/t/zW1IkU9aQr
You need to change the number '3749' in the above snippet to the badge ID on your site.
Best regards,
Dustin