Answers for "Woocommerce Display field value on the admin order edit page [Custom Field Display 2]"

PHP
0

Woocommerce Display field value on the admin order edit page [Custom Field Display 2]

/**
 * Display field value on the admin order edit page..
 *
 * PHP Custom Feild Value
 * 
 * 
 */

add_action( 'woocommerce_admin_order_data_after_billing_address', 'my_custom_checkout_field_display_admin_order_meta', 10, 1 );
function my_custom_checkout_field_display_admin_order_meta($order){
    echo '<p><strong>'.__('Store Location').':</strong> ' . get_post_meta( $order->id, 'My Field', true ) . '</p>';
}
Posted by: Guest on November-19-2020
0

Woocommerce Update the Order meta with Custom Field value [Custom Field Display 1]

/**
 * Update the order meta with field value
 *
 * PHP Custom Feild Value
 * 
 * 
 */

add_action( 'woocommerce_checkout_update_order_meta', 'my_custom_checkout_field_update_order_meta' );
function my_custom_checkout_field_update_order_meta( $order_id ) {
    if ( ! empty( $_POST['store_location'] ) ) {
        update_post_meta( $order_id, 'My Field', sanitize_text_field( $_POST['store_location'] ) );
    }
}
Posted by: Guest on November-19-2020

Code answers related to "Woocommerce Display field value on the admin order edit page [Custom Field Display 2]"

Browse Popular Code Answers by Language