1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
/* * Add a referanse field to the checkout. */ function prefix_checkout_add_referanse_field( $fields ) { $fields['billing']['billing_referanse'] = array( 'label' => __( 'Referanse', 'woocommerce' ), 'placeholder' => '', 'required' => false, 'class' => array('form-row-wide'), 'clear' => true ); return $fields; } add_filter( 'woocommerce_checkout_fields' , 'prefix_checkout_add_referanse_field' ); /** * Display field referanse value on the order edit page. */ function prefix_order_display_referanse_field( $order ) { $referanse_meta_field = get_post_meta( $order->get_id(), '_billing_referanse', true ); if ( $referanse_meta_field ) echo '<p><strong>'. __('Referanse') .':</strong> ' . esc_attr( get_post_meta( $order->get_id(), '_billing_referanse', true ) ) . '</p>'; } add_action( 'woocommerce_admin_order_data_after_shipping_address', 'prefix_order_display_referanse_field', 10, 1 ); |