Support » Plugin: Checkout Field Editor (Checkout Manager) for WooCommerce » How to get value of SELECT field to compare?

  • Resolved botdesigns

    (@botdesigns)


    I want to apply fees based on value selected on my checkout page.
    I have created field as ‘billing_district’.
    I want to compare value against this SELECT id i.e. billing_district.

    I tried below 2 ways,

    1. $value= $_POST[‘billing_district’];
    2. $value = WC()->customer->billing_district;

    but I am not getting the value which is selected by customer.
    How can I get the value?

    Thanks in advance!

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author ThemeHigh

    (@themehigh)

    If your action is after submitting an order then the field value will be available in $_POST[‘billing_district’] variable.

    If your action is like ‘woocommerce_cart_calculate_fees’ etc in checkout page, you have to trigger ‘update_checkout’ action using javascript on your input change. Then you can get the field value from $_POST[‘post_data’] variable. The $_POST[‘post_data’] variable will be a query string and you need to parse the query string. You can use the below code snippet.

    $post_data = isset($_POST['post_data']) ? $_POST['post_data'] : '';
    
    if($post_data){
    parse_str($post_data, $post_data_arr);
    $value = isset($post_data_arr['billing_district']) ? stripslashes($post_data_arr['billing_district']) : '';
    }

    We hope this will help.

    Thank you!

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.