单击动态创建的单选按钮时如何更新woocommerce总金额

时间:2018-12-10 13:04:36

标签: php wordpress woocommerce advanced-custom-fields

function custom_amount_display() {
    // Only run this code if Registrations for the Events Calendar is active
  $event_id                = get_the_ID();
?>
<span><strong>The course manual is included with the course.</strong></span>
<table>
  <?php
      if (have_rows('course_manual')):
        $c=0;
      while (have_rows('course_manual')): 
        $c++;
      the_row();
  ?>
  <tr>
    <th><?php the_sub_field('manual_text'); ?></th>
    <th>
      <label class="radio-inline">
      <input type="radio" name="manual<?php echo($c);?>" class="manual_price" data-prce="0" value="0" checked>No
    </label>
    <label class="radio-inline">
      <input type="radio" name="manual<?php echo($c);?>" class="manual_price" data-prce="<?php the_sub_field('amount'); ?>" value="1">Yes (add $<?php the_sub_field('amount'); ?>)
    </label>
    </th>
  </tr>
  <?php 
      endwhile;
     endif;
  ?>
</table>
<?php

}
add_action( 'tribe_events_single_event_after_the_content', 'custom_amount_display' );

这是我的示例https://www.screencast.com/t/sMVz4WbbB
当我单击单选按钮时,相应的金额将被添加到总金额中
这些单选按钮是使用ACF插件创建的

add_action( 'wp_footer', 'checkout_total_script' );
function checkout_total_script() {
    //if ( ! is_checkout() )
        //return; // Only checkout page
    ?>
    <script type="text/javascript">
    jQuery( function($){
        $('.manual_price').click(function(){
          var pr = $(this).data('prce');
          alert(pr);
        })
    });
    </script>
    <?php

}

我如何更新总额

0 个答案:

没有答案