0

i am trying to change the total price of a order instantly when a user checks the checkmark for signing up to the newsletter.

I have so far managed to make a jquery function that looks for on change and then logs every update.

But i cannot figure out (if its even possible), how to implement a new total price, which should go back up when checkmark is removed.

The code i have so far is

add_action('wp_footer', 'add_code');
function add_code(){
?>
<script>
jQuery(function($) {
    $(document.body).on("change", "#subscribe_to_newsletter", function () {
      var checked = $(this).prop("checked");
        
        
     if (checked) {
         var consoletext = '<?php echo "Virker" ?>';
         console.log(consoletext);
      } else {
        console.log("virker ikke");
      }
        
        
    });
  });
</script>

<?php }

the page it is on is just a practice page so you can check it here: https://tobiasbyg.offbeatmedia.dk/kasse/

  • https://stackoverflow.com/questions/57613334/display-a-checkbox-that-add-a-fee-in-woocommerce-checkout-page – Snuffy Dec 14 '22 at 12:09

0 Answers0