Save and display specific payment gateway additional field everywhere in Woocommerce

前端 未结 2 1402
傲寒
傲寒 2021-01-25 13:29

I am using \"Additional field on checkout for specific payment gateway in Woocommerce\" answer code, that displays an additional dropdown field for specific payment gat

2条回答
  •  无人共我
    2021-01-25 14:01

    add_action('woocommerce_checkout_update_order_meta', 'custom_checkout_field_update_order_meta');

    function custom_checkout_field_update_order_meta($order_id)

    {

    if (!empty($_POST['field_slug'])) {

    update_post_meta($order_id, 'Some key',sanitize_text_field($_POST['field_slug']));

    }

    } to fetch this value in order details or email template page you can use get_post_meta($order_id, 'Some key',false);

提交回复
热议问题