Adding CC# Checkout Field

/**
* @snippet Add Custom Field @ WooCommerce Checkout Page
* @how-to Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @testedwith WooCommerce 3.8
* @donate $9 https://businessbloomer.com/bloomer-armada/
*/

add_action( 'woocommerce_after_checkout_billing_form', 'bbloomer_add_custom_ccno_checkout_field' );

function bbloomer_add_custom_ccno_checkout_field( $checkout ) {
$current_user = wp_get_current_user();
$saved_creditcard_no = $current_user->creditcard_no;
woocommerce_form_field( 'creditcard_no', array(
'type' => 'text',
'class' => array( 'form-row-wide' ),
'label' => 'Credit Card # (Your card will be charged when the order is shipped)',
'placeholder' => '1234567890',
'required' => false,
'default' => $saved_creditcard_no,
), $checkout->get_value( 'creditcard_no' ) );
}

/**
* @snippet Validate Custom Field @ WooCommerce Checkout Page
* @how-to Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @testedwith WooCommerce 3.8
* @donate $9 https://businessbloomer.com/bloomer-armada/
*/

add_action( 'woocommerce_checkout_process', 'bbloomer_validate_new_ccno_checkout_field' );

function bbloomer_validate_new_ccno_checkout_field() {
if ( ! $_POST['creditcard_no'] ) {
wc_add_notice( 'Please enter your CC number', 'error' );
}
}

/**
* @snippet Save & Display Custom Field @ WooCommerce Order
* @how-to Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @testedwith WooCommerce 3.8
* @donate $9 https://businessbloomer.com/bloomer-armada/
*/

add_action( 'woocommerce_checkout_update_order_meta', 'bbloomer_save_new_ccno_checkout_field' );

function bbloomer_save_new_ccno_checkout_field( $order_id ) {
if ( $_POST['creditcard_no'] ) update_post_meta( $order_id, '_creditcard_no', esc_attr( $_POST['creditcard_no'] ) );
}

add_action( 'woocommerce_admin_order_data_after_billing_address', 'bbloomer_show_new_ccno_checkout_field_order', 10, 1 );

function bbloomer_show_new_ccno_checkout_field_order( $order ) {
$order_id = $order->get_id();
if ( get_post_meta( $order_id, '_creditcard_no', true ) ) echo '

Credit Card Number: ‘ . get_post_meta( $order_id, ‘_creditcard_no’, true ) . ‘

‘; } //add_action( ‘woocommerce_email_after_order_table’, ‘bbloomer_show_new_ccno_checkout_field_emails’, 20, 4 ); //function bbloomer_show_new_ccno_checkout_field_emails( $order, $sent_to_admin, $plain_text, $email ) { // if ( get_post_meta( $order->get_id(), ‘_creditcard_no’, true ) ) echo ‘

Credit Card Number: ‘ . get_post_meta( $order->get_id(), ‘_creditcard_no’, true ) . ‘

‘; //}