Home Forums WoodMart support forum Bug in the WoodMart Checkout Fields editor with the “country” dropdown field

Bug in the WoodMart Checkout Fields editor with the “country” dropdown field

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #581555

    Jeriss Cloud Center
    Participant

    As soon as I change the country, the row gets a weird / broken style.

    If I put back default store country from the WooCommerce settings (here, Belgium), the style reverts to the correct behavior on page refresh. Else, it remains broken.

    Check video attached.

    Attachments:
    You must be logged in to view attached files.
    #581643

    Artem Temos
    Keymaster

    Hello,

    Please, provide us with your admin access so we can log in and check this on your side.

    Thank you in advance.

    #581713

    Jeriss Cloud Center
    Participant

    Access below.

    1) All plugins are disabled
    2) All customizations are removed.
    3) Parent theme is enabled.

    #582009

    Artem Temos
    Keymaster

    1. Try to edit the file wp-content\themes\woodmart\inc\integrations\woocommerce\modules\checkout-fields\class-frontend.php and find the following method update_checkout_fields (https://monosnap.com/file/hrrXZuVGBi2CcjmQ03hOZl8XtVTy9T)

    2. Replace it with the following code

    public function update_checkout_fields( $checkout_fields ) {
    		if ( ! woodmart_get_opt( 'checkout_fields_enabled' ) || ! is_checkout() ) {
    			return $checkout_fields;
    		}
    
    		$change_options = get_option( 'xts_checkout_fields_manager_options', array() );
    
    		if ( empty( $change_options ) ) {
    			return $checkout_fields;
    		}
    
    		foreach ( $change_options as $group_key => $checkout_groups_fields ) {
    			if ( ! isset( $checkout_fields[ $group_key ] ) ) {
    				continue;
    			}
    
    			foreach ( $checkout_groups_fields as $field_key => $checkout_field ) {
    				if ( isset( $checkout_field['status'] ) && ! $checkout_field['status'] ) {
    					unset( $checkout_fields[ $group_key ][ $field_key ] );
    
    					continue;
    				}
    
    				if ( ! isset( $checkout_fields[ $group_key ][ $field_key ] ) ) {
    					$checkout_fields[ $group_key ][ $field_key ] = $checkout_field;
    					continue;
    				}
    
    				// Remove screen reader.
    				if ( isset( $checkout_fields[ $group_key ][ $field_key ]['label_class'] ) && is_array( $checkout_fields[ $group_key ][ $field_key ]['label_class'] ) && in_array( 'screen-reader-text', $checkout_fields[ $group_key ][ $field_key ]['label_class'], true ) ) {
    					unset( $checkout_fields[ $group_key ][ $field_key ]['label_class'][ array_search( 'screen-reader-text', $checkout_fields[ $group_key ][ $field_key ]['label_class'], true ) ] );
    				}
    
    				// Remove old position class before added new.
    				$remove_classes    = array();
    				$positions_classes = array(
    					'form-row-first',
    					'form-row-wide',
    					'form-row-last',
    				);
    
    				foreach ( $positions_classes as $positions_class ) {
    					$remove_classes[] = array_search( $positions_class, $checkout_fields[ $group_key ][ $field_key ]['class'], true );
    				}
    
    				$remove_classes = array_filter(
    					array_unique( $remove_classes ),
    					function ( $el ) {
    						return $el || 0 === $el;
    					}
    				);
    
    				if ( ! empty( $remove_classes ) ) {
    					foreach ( $remove_classes as $id ) {
    						unset( $checkout_fields[ $group_key ][ $field_key ]['class'][ $id ] );
    					}
    				}
    
    				$checkout_fields[ $group_key ][ $field_key ] = $this->helper->recursive_parse_args( $checkout_field, $checkout_fields[ $group_key ][ $field_key ] );
    			}
    		}
    
    		return $checkout_fields;
    	}
    #582052

    Jeriss Cloud Center
    Participant

    Hello,

    I did as you suggested but it’s not good.

    1) The problem with the Country dropdown is not solved (despite clearing cache, and even despite resetting all fields to their default in the Checkout Editor)

    2) Now worse, the First Name and Last Name are showing Wide whereas I defined them as Left and Right.

    Please check again
    Thanks

    #582065

    Artem Temos
    Keymaster

    We see that you didn’t make any changes in the mentioned file. Please do this now and test how it works.

    #582066

    Jeriss Cloud Center
    Participant

    I did it on my live site

    #582069

    Jeriss Cloud Center
    Participant

    I just replaced it on the staging too, and same problem as reported above.

    #582073

    Artem Temos
    Keymaster

    Try to replace that code with the following one instead

    public function update_checkout_fields( $checkout_fields ) {
    		if ( ! woodmart_get_opt( 'checkout_fields_enabled' ) || ! is_checkout() ) {
    			return $checkout_fields;
    		}
    
    		$change_options = get_option( 'xts_checkout_fields_manager_options', array() );
    
    		if ( empty( $change_options ) ) {
    			return $checkout_fields;
    		}
    
    		foreach ( $change_options as $group_key => $checkout_groups_fields ) {
    			if ( ! isset( $checkout_fields[ $group_key ] ) ) {
    				continue;
    			}
    
    			foreach ( $checkout_groups_fields as $field_key => $checkout_field ) {
    				if ( isset( $checkout_field['status'] ) && ! $checkout_field['status'] ) {
    					unset( $checkout_fields[ $group_key ][ $field_key ] );
    
    					continue;
    				}
    
    				if ( ! isset( $checkout_fields[ $group_key ][ $field_key ] ) ) {
    					$checkout_fields[ $group_key ][ $field_key ] = $checkout_field;
    					continue;
    				}
    
    				// Remove screen reader.
    				if ( isset( $checkout_fields[ $group_key ][ $field_key ]['label_class'] ) && is_array( $checkout_fields[ $group_key ][ $field_key ]['label_class'] ) && in_array( 'screen-reader-text', $checkout_fields[ $group_key ][ $field_key ]['label_class'], true ) ) {
    					unset( $checkout_fields[ $group_key ][ $field_key ]['label_class'][ array_search( 'screen-reader-text', $checkout_fields[ $group_key ][ $field_key ]['label_class'], true ) ] );
    				}
    
    				// Remove old position class before added new.
    				if ( isset( $checkout_field['class'] ) ) {
    					$remove_classes    = array();
    					$positions_classes = array(
    						'form-row-first',
    						'form-row-wide',
    						'form-row-last',
    					);
    
    					foreach ( $positions_classes as $positions_class ) {
    						$remove_classes[] = array_search( $positions_class, $checkout_fields[ $group_key ][ $field_key ]['class'], true );
    					}
    
    					$remove_classes = array_filter(
    						array_unique( $remove_classes ),
    						function ( $el ) {
    							return $el || 0 === $el;
    						}
    					);
    
    					if ( ! empty( $remove_classes ) ) {
    						foreach ( $remove_classes as $id ) {
    							unset( $checkout_fields[ $group_key ][ $field_key ]['class'][ $id ] );
    						}
    					}
    
    					$checkout_fields[ $group_key ][ $field_key ] = $this->helper->recursive_parse_args( $checkout_field, $checkout_fields[ $group_key ][ $field_key ] );
    				}
    			}
    		}
    
    		return $checkout_fields;
    	}
    #582103

    Jeriss Cloud Center
    Participant

    1) The regression about the First Name and Last Name is solved

    2) But the initial issue about the country is still there.

    Try by yourself on the staging. I installed a File Editor where you can test your code by yourself.

    Then go to checkout and try a country like Spain for instance (“Espagne”)

    #582471

    Artem Temos
    Keymaster

    We have fixed this on the staging website. Please test it and let me know if it works.
    You can copy the following file to your live website to test it there wp-content\themes\woodmart\inc\integrations\woocommerce\modules\checkout-fields\class-frontend.php

    Kind Regards

    #582476

    Jeriss Cloud Center
    Participant

    it’s working good now thanks !

    #582481

    Jeriss Cloud Center
    Participant

    You can close this ticket

    #582564

    Artem Temos
    Keymaster

    You are always welcome. Feel free to contact us if you have any further questions.

Viewing 14 posts - 1 through 14 (of 14 total)

The topic ‘Bug in the WoodMart Checkout Fields editor with the “country” dropdown field’ is closed to new replies.