Purchase Order Number on the Block Checkout
Adds an optional "Purchase order number" field to the Checkout block for business buyers, saved on the order with WooCommerce's additional fields API.
Opens WPIDE on
Code
add_action( 'woocommerce_init', function () {
if ( ! function_exists( 'woocommerce_register_additional_checkout_field' ) ) {
return;
}
woocommerce_register_additional_checkout_field( array(
'id' => 'wpide/po-number',
'label' => 'Purchase order number (optional)',
'location' => 'order',
'type' => 'text',
'required' => false,
'attributes' => array(
'maxLength' => 40,
'autocomplete' => 'off',
),
) );
} );
Notes
Needs WooCommerce 8.9 or newer, and the value appears on the order screen, in emails and on the confirmation page automatically.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.