Show hide custom Woocommerce checkout field based on selected payment method

后端 未结 1 434
温柔的废话
温柔的废话 2020-12-06 23:26

Hi I added custom field in billing form using this code below.

add_filter(\'woocommerce_billing_fields\', \'custom_woocommerce_billing_fields\');

function c         


        
1条回答
  •  北海茫月
    2020-12-06 23:47

    The following code will hide billing_options custom optional checkout field when the selected payment method is Cash on delivery ("cod"):

    // Conditional Show hide checkout fields based on chosen payment methods
    add_action( 'wp_footer', 'conditionally_show_hide_billing_custom_field' );
    function conditionally_show_hide_billing_custom_field(){
        // Only on checkout page
         if ( is_checkout() && ! is_wc_endpoint_url() ) :
        ?>
        
        

    Code goes in function.php file of your active child theme (or active theme). tested and works.

    0 讨论(0)
提交回复
热议问题