Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • I am trying to add a select field to billing page.. I have successfully added, but it is not displaying the placeholder text and the first option is selected. Need it to show the placeholder so the user must make a selection. Am I missing something here?

    <?php
    /**
    * Add the field to the checkout
    **/
    add_action('woocommerce_before_order_notes', 'my_club_checkout_field');
    
    function my_club_checkout_field( $checkout ) {
    
    echo '<div id="my_local_club"><h3>'.__('Local Club').'</h3>';
    
    woocommerce_form_field( 'local_club', array(
    'type' => 'select',
    'class' => array('my-club-class form-row-wide'),
    'label'       			=> __('<br><br>Please Select your Local Club', 'woocommerce'),
    'required'    			=> true,
    'placeholder' => _x('Please Select An Option...', 'placeholder','woocommerce'),
        'options'			=> array(
            'option_a' 	=> __('Lees Summit', 'woocommerce' ),
            'option_b' 	=> __('Kansas City', 'woocommerce' )
         )
    ), $checkout->get_value( 'local_club' ));
    
    echo '</div>';
    
    }
    
    /**
    * Process the checkout
    **/
    add_action('woocommerce_checkout_process', 'my_club_checkout_field_process');
    
    function my_club_checkout_field_process() {
    global $woocommerce;
    }
    
    /**
    * Update the order meta with field value
    **/
    add_action('woocommerce_checkout_update_order_meta', 'my_club_checkout_field_update_order_meta');
    
    function my_custom_checkout_field_update_order_meta( $order_id ) {
    if ($_POST['local_club']) update_post_meta( $order_id, 'My Club', esc_attr($_POST['local_club']));
    }
    
    /**
    * Display field value on the order edition page
    **/
    add_action( 'woocommerce_admin_order_data_after_billing_address', 'my_club_checkout_field_display_admin_order_meta', 10, 1 );
    
    function my_club_checkout_field_display_admin_order_meta($order){
    echo '<p>'.__('local_club').': ' . $order->order_custom_fields['My Club'][0] . '</p>';
    }
    Thread Starter dezahyner

    (@dezahyner)

    I also tried……

    if( !is_user_logged_in() && is_product(7854))  {
    	wp_redirect('my-site-url');
    	exit;
    }
    else

    and again.. when you click on any product, it redirects to login, even though, I have specified the product id..

    Thoughts?

    can you share your javascript on how you were able to successfully submit comments?

    You were able to post comments from you app? Could you share the code on how to do this? Were you able to find a solution for registering users?

Viewing 4 replies - 1 through 4 (of 4 total)