woocommerce_form_field and hidden fields

前端 未结 5 678
[愿得一人]
[愿得一人] 2021-01-14 17:18

I\'m trying to add custom fields to the WooCommerce checkout and there seems to be no output for hidden fields.

In woocommerce-template.php, hidden fie

5条回答
  •  臣服心动
    2021-01-14 17:59

    I know it's been awhile since you asked this question, but I found something that worked for me. I was able to get around a hidden field by posting certain information to the post meta.

    This is what I did:

    add_action( 'woocommerce_checkout_update_order_meta', 'your_hidden_data' );
    
    function your_hidden_data( $order_id ) {
        /*
          Put your normal field saves here
        */
    
        //Your hidden fields
        update_post_meta( $order_id, 'YOUR DESIRED KEY NAME', 'YOUR DESIRED VALUE' );
    }
    

    Above where I have "YOUR DESIRED VALUE, I placed a function that returned a number that I needed saved to the order.

    Hopefully this is not too specific to my own application.

提交回复
热议问题