\nvar AddressFinderConfig = {};\n"; if($af_key_nz) { echo "AddressFinderConfig.key_nz = '{$af_key_nz}';\n"; } if($af_key_au) { echo "AddressFinderConfig.key_au = '{$af_key_au}';\n"; } if ($af_widget_options) { $encoded_json = json_encode($af_widget_options); echo "AddressFinderConfig.widget_options = {$encoded_json};\n"; } if($af_debug == 'yes') { echo "AddressFinderConfig.debug = true;\n"; } if ($af_default_country) { echo "AddressFinderConfig.default_country = '{$af_default_country}';\n"; } echo "\n"; echo ''; } add_filter( 'woocommerce_get_settings_checkout', 'addressfinder_settings', 10, 1 ); function addressfinder_settings( $settings ) { $settings[] = array( 'name' => __( 'AddressFinder Settings', 'text-domain' ), 'type' => 'title', 'desc' => __( 'AddressFinder supports New Zealand and Australia.', 'text-domain' ), 'id' => 'addressfinder-widget' ); $af_key_nz = esc_attr( get_option( 'af-key' ) ); $af_key_au = esc_attr( get_option( 'af-key-au' ) ); if($af_key_nz && $af_key_au) { $settings[] = array( 'name' => __( 'Licence key for New Zealand', 'text-domain' ), 'desc_tip' => __( 'The key shown in the AddressFinder portal', 'text-domain' ), 'id' => 'af-key', 'type' => 'text', 'desc' => __( 'Find your AddressFinder Key from AddressFinder Portal', 'text-domain' ), ); $settings[] = array( 'name' => __( 'Licence key for Australia', 'text-domain' ), 'desc_tip' => __( 'The key shown in the AddressFinder Australian portal', 'text-domain' ), 'id' => 'af-key-au', 'type' => 'text', 'desc' => __( 'Find your AddressFinder Key from AddressFinder Portal', 'text-domain' ), ); } elseif ($af_key_au) { $settings[] = array( 'name' => __( 'Licence key', 'text-domain' ), 'desc_tip' => __( 'The key shown in the AddressFinder Australian portal', 'text-domain' ), 'id' => 'af-key-au', 'type' => 'text', 'desc' => __( 'Find your AddressFinder Key from AddressFinder Portal', 'text-domain' ), ); } else { $settings[] = array( 'name' => __( 'Licence key', 'text-domain' ), 'desc_tip' => __( 'The key shown in the AddressFinder portal', 'text-domain' ), 'id' => 'af-key', 'type' => 'text', 'desc' => __( 'Find your AddressFinder Key from AddressFinder Portal', 'text-domain' ), ); } $settings[] = array( 'name' => __( 'Widget Options', 'text-domain' ), 'id' => 'af-widget-options', 'type' => 'textarea', 'placeholder' => __('Eg: {"byline": true}', 'text-domain'), 'desc' => __('
Additional options that allow you to adjust the default behaviour of the widget. These options should be in the form of a JSON string with proper quoting of keys.
This section may be left blank for default behaviour.
For a full list of possible options see our Widget documentation
', 'text-domain'), ); $settings[] = array( 'name' => __( 'Debug Mode', 'text-domain' ), 'id' => 'af-debug', 'type' => 'checkbox', 'desc' => __( 'Show error messages when expected fields are missing', 'text-domain' ), ); $settings[] = array( 'name' => __( 'Default Country', 'text-domain' ), 'desc' => __( 'If the checkout page does not have country selector form field, addresses from this country will be displayed', 'text-domain' ), 'id' => 'af-default-country', 'default' => 'NZ', 'type' => 'select', 'options' => array( 'au' => __( 'Australia', 'text-domain' ), 'nz' => __( 'New Zealand', 'text-domain' ) ), ); $settings[] = array( 'type' => 'sectionend', 'id' => 'addressfinder-widget' ); return $settings; } } ?>