Reputation: 90
I have the latest version of wordpress and woocommerce, and I have try to add some custom field with my order like this :
function custom_checkout_field_update_order_meta($order_id)
{
if(!empty($_POST['DATE']))
{
update_post_meta($order_id, 'DATE', sanitize_text_field($_POST['DATE']));
}
if(!empty($_POST['HOURS']))
{
update_post_meta($order_id, 'HOURS', sanitize_text_field($_POST['HOURS']));
}
}
add_action('woocommerce_checkout_update_order_meta', 'custom_checkout_field_update_order_meta');
Everything works well, and I can show the diffent field in the admin orders with this function :
function custom_checkout_field_display_admin_order_meta($order)
{
?>
<p>
<strong>Date :</strong><br>
<?=get_post_meta($order->id, 'DATE', true);?>
</p>
<p>
<strong>Date :</strong><br>
<?=get_post_meta($order->id, 'HOURS', true);?>
</p>
<?php
}
add_action('woocommerce_admin_order_data_after_billing_address', 'custom_checkout_field_display_admin_order_meta', 10, 1);
But I want to show the custom field like the woocommerce doc (on the bottom of the screen) :
But I don't understand how see this, I have look on the "options" checkbox (on the top right) but all is checked, and I have no option for "custom field", so maybe woocommerce remove this part on the lastest version ?
Thanks
UPDATE :
For me the problem was because of "ACF Pro" plugin who remove that checkbox field, if you want to have both (Woocommerce custom field + ACF Pro custom field) you can just add this code snippet into your function.php
:
add_filter('acf/settings/remove_wp_meta_box', '__return_false', 20);
Upvotes: 1
Views: 1206
Reputation: 107
Check screen options
on top of the orders page and check if the custom fields
are checked or not. If custom fields are not checked then it will not show on the page. You can check the screenshots: http://prntscr.com/vug7g8
Upvotes: 1