Thursday, July 28, 2022
HomeWordPress Developmentwoocommerce offtopic - Customized subject in Buyer Registration kind

woocommerce offtopic – Customized subject in Buyer Registration kind


Within the Consumer Registration kind I need to add a customized textual content subject the place the person can fill in a task(or every other textual content)

I am utilizing these 2 features to show the sector after which put it aside to the Consumer. Proper now the sector shows however the billing_role does not get saved to the Consumer.

I am testing this in one other perform the place all of the Consumer knowledge will get proven

<?php
perform wooc_extra_register_fields() {
    $billing_role = ! empty( $_POST['billing_role'] ) ? intval( $_POST['billing_role'] ) : '';
    ?>
       <p class="form-row form-row-wide">
       <label for="billing_role"><?php _e( 'billing_role', 'woocommerce' ); ?></label>
       <enter sort="textual content" class="input-text" identify="billing_role" id="billing_role" worth="<?php echo esc_attr( $billing_role ); ?>" />
       </p>
       <div class="clear"></div>
       <?php
 }
 add_action( 'woocommerce_register_form_start', 'wooc_extra_register_fields' );

/**
* save additional subject.
*/
perform wooc_save_extra_register_fields($customer_id) {
    echo $customer_id;
    if ( ! empty( $_POST['billing_role'] ) ) {
        update_user_meta( $customer_id, 'billing_role', sanitize_text_field( $_POST['billing_role'] ) );
    }
}
add_action( 'woocommerce_created_customer', 'wooc_save_extra_register_fields' );

What’s the appropriate means to do that? Thanks upfront

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments