• Resolved ___ripa___

    (@ripa01)


    I would like to use only the woocommerce registration form that at the moment is only avaible in the shipping page, i’d like that every user that would like to sign up the first time use the woocommerce form and i’d like to set personalized user role based on registration input value. How can i do?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter ___ripa___

    (@ripa01)

    add_action(‘woocommerce_checkout_update_order_meta’, ‘wps_select_checkout_field_update_order_meta’);
    function wps_select_checkout_field_update_order_meta( $order_id ) {

    if ($_POST[‘professione’]) update_post_meta( $order_id, ‘professione’, esc_attr($_POST[‘professione’]));
    if ($_POST[‘partita_IVA’]) update_post_meta( $order_id, ‘partita_IVA’, esc_attr($_POST[‘partita_IVA’]));
    if ($_POST[‘ragsoc’]) update_post_meta( $order_id, ‘ragsoc’, esc_attr($_POST[‘ragsoc’]));

    }

    add_action(‘woocommerce_checkout_process’, ‘wps_select_checkout_field_process’);
    function wps_select_checkout_field_process() {
    global $woocommerce;

    // Check if set, if its not set add an error.
    if ($_POST[‘professione’] == “blank”)
    wc_add_notice( ‘Seleziona una professione‘, ‘error’ );
    elseif (($_POST[‘professione’] != “privato”) && ($_POST[‘ragsoc’] == “”))
    wc_add_notice( ‘Inserisci la tua ragione sociale‘, ‘error’ );
    elseif (($_POST[‘professione’] != “privato”) && ($_POST[‘partita_IVA’] == “”))
    wc_add_notice( ‘Inserisci la tua Partita IVA‘, ‘error’ );

    }

    add_action( ‘woocommerce_admin_order_data_after_billing_address’, ‘wps_select_checkout_field_display_admin_order_meta’, 10, 1 );
    function wps_select_checkout_field_display_admin_order_meta($order){

    echo ‘<p>‘.__(‘Professione’).’: ‘ . get_post_meta( $order->id, ‘professione’, true ) . ‘</p><p>‘.__(‘Ragione sociale’).’: ‘ . get_post_meta( $order->id, ‘ragsoc’, true ) . ‘</p><p>‘.__(‘Partita IVA’).’: ‘ . get_post_meta( $order->id, ‘partita_IVA’, true ) . ‘</p>’;

    }

    //* Add selection field value to emails
    add_filter(‘woocommerce_email_order_meta_keys’, ‘wps_select_order_meta_keys’);
    function wps_select_order_meta_keys( $keys ) {

    $keys[‘professione:’] = ‘professione’;
    $keys[‘partita_IVA:’] = ‘partita_IVA’;
    $keys[‘ragsoc:’] = ‘ragsoc’;
    return $keys;

    }

    i added this part of code to check my costumer role and i created relative roles but i can’t associate them

    Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    Hi there ??

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Cheers!

    Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    We’ve not seen any activity on this thread for a while, so I’m marking this thread as resolved.

    Hopefully, you were able to find a solution to your problem! If you have further questions, please feel free to open a new topic.

    Cheers!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Use only the woocommerce form to sign up on website and set personalized role’ is closed to new replies.