• Resolved Gauravbhai Daxini

    (@daxinigaurav)


    I have installed this plugin to add extra fields in checkout page. later on i have used polylang for multi languages. i am using default language is non english and when i select it from admin side and added translation for english then it is not working.

Viewing 1 replies (of 1 total)
  • Thread Starter Gauravbhai Daxini

    (@daxinigaurav)

    Here i found the solution:

    /wc-fields-factory/includes/wcff_checkout_fields.php

    /* To render custom checkout field */
        public function wcccf_custom_checkout_fields(){
            
            $checkout_custom_meta = $this->get_fields_meta( 'custom-fields' );
            $checkout_custom_fields = array();
            foreach( $checkout_custom_meta as $name => $val ){
                $checkout_custom_fields[$name] = json_decode( $val[0], true );
            }
            
            foreach ($checkout_custom_fields as $key => $field) {
    
                $is_enable = isset($field["is_enable"]) ? $field["is_enable"] : true;
                if (is_array($field) && isset($field["key"]) && $this->check_login_user($field) && $is_enable) {
                    $wccpf_options = wcff()->option->get_options();
                    $multilingual = isset($wccpf_options["enable_multilingual"]) ? $wccpf_options["enable_multilingual"] : "no";
                    if ($multilingual == "yes") {
            			/* Localize field */
            			$field = wcff ()->locale->localize_field ( $field );
            		}
                    $field["name"] = $field["key"];
                    $field["required"] = isset( $field["required"] ) && $field["required"] == "yes" ? true : false;
                    $field["cloneable"] = "no";
                    $field["for_front_end"] = true;
                    echo wcff()->builder->build_user_field( $field, "wcccf", true );
                }
    
            }
        }

    /wc-fields-factory/includes/wcff_locale.php

    public function localize_field($_field) {
    
        	/* Determine the current locale */
        	$locale = $this->detrmine_current_locale();
        	/* Well start the translation */
        	$wcff_options = wcff()->option->get_options();
            $default_locale = isset($wcff_options["default_locale"]) ? $wcff_options["default_locale"] : "en"; 
        	if($locale != $default_locale) {
        		if(isset($_field["locale"]) && isset($_field["locale"][$locale])) {
        			$resources = $_field["locale"][$locale];
        			if($resources) {
        				foreach ($_field as $key => $value) {
        					if($key != "locale") {
        						if(isset($resources[$key]) && $resources[$key] != "") {
        							$_field[$key] = $resources[$key];
        						}
        					}
        				}
        			}
                    
        			/* Remove locale property from the $_field argument
        			 * as it is no longer needed */
        			//unset($_field["locale"]);
        		}
        	}    	
        	return $_field;
        }

    I hope this code useful to this community and Plugin auther will fix in next release version.

    Thanks.

Viewing 1 replies (of 1 total)
  • The topic ‘Translation is not working in checkout fields’ is closed to new replies.