Viewing 5 replies - 1 through 5 (of 5 total)
  • it looks like there’s a structural problem with your html –
    a closing </p> before the country field. Something must be amiss with your wc template files

    Thread Starter gstricklind

    (@gstricklind)

    That’s what I thought too.
    I looked at the template files and the coding seems to be correct. Anything I missed?

    Here’s the coding from woocommerce/woocomerce-tempalte.php line 1102-1124 (country – beginning of state)

    case "country" :
    
    			$field = '<p class="form-row ' . implode( ' ', $args['class'] ) .'" id="' . $key . '_field">
    					<label for="' . $key . '" class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label']. $required  . '</label>
    					<select name="' . $key . '" id="' . $key . '" class="country_to_state ' . implode( ' ', $args['class'] ) .'">
    						<option value="">'.__( 'Select a country&hellip;', 'woocommerce' ) .'</option>';
    
    			foreach ( $woocommerce->countries->get_allowed_countries() as $ckey => $cvalue ) {
    				$field .= '<option value="' . $ckey . '" '.selected( $value, $ckey, false ) .'>'.__( $cvalue, 'woocommerce' ) .'</option>';
    			}
    
    			$field .= '</select>';
    
    			$field .= '<noscript><input type="submit" name="woocommerce_checkout_update_totals" value="' . __('Update country', 'woocommerce') . '" /></noscript>';
    
    			$field .= '</p>' . $after;
    
    			break;
    		case "state" :

    Thread Starter gstricklind

    (@gstricklind)

    I hated to do this but I had to edit the plugin file and create a negative margin; and thought I’d post what fixed it just in case someone else has this problem or if this could possibly be a bug that can be fixed with the next release.

    case "country" :
    
    			$field = '<p class="form-row ' . implode( ' ', $args['class'] ) .'" id="' . $key . '_field">';
    			$field .= '<label for="' . $key . '" class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label']. $required  . '</label>';
    			$field .= '<select name="' . $key . '" id="' . $key . '" class="country_to_state ' . implode( ' ', $args['class'] ) .'">';
    			$field .= '<option value="">'.__( 'Select a country&hellip;', 'woocommerce' ) .'</option>';
    
    			foreach ( $woocommerce->countries->get_allowed_countries() as $ckey => $cvalue ) {
    				$field .= '<option value="' . $ckey . '" '.selected( $value, $ckey, false ) .'>'.__( $cvalue,

    Thanks gstricklind, I was having the same issue. Not sure how our template files had these bugs while most apparently didn’t.

    I tried your fix and must be missing something. I too have the same problem for a site in development. I updated my woocommerce-templae.php as follows

    case "country" :
    
                $field = '<p class="form-row ' . implode( ' ', $args['class'] ) .'" id="' . $key . '_field">';
    			$field .= '<label for="' . $key . '" class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label']. $required  . '</label>';
    			$field .= '<select name="' . $key . '" id="' . $key . '" class="country_to_state ' . implode( ' ', $args['class'] ) .'">';
    			$field .= '<option value="">'.__( 'Select a country&hellip;', 'woocommerce' ) .'</option>';
    
    			foreach ( $woocommerce->countries->get_allowed_countries() as $ckey => $cvalue ) {
    				$field .= '<option value="' . $ckey . '" '.selected( $value, $ckey, false ) .'>'.__( $cvalue,
    
    	        }

    All I managed to do was break the site. Can you tell me what I am doing wrong please?

    Thanks

    https://microscanada.onlyhospitality.com/shop/

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Checkout form fields have bad positioning’ is closed to new replies.