2016-11-15 2 views
-2

Wordpress-Plugin verwenden und es Land mit WooCommerce Drop-Down-Arbeit, es Text Land zeigt nur, Am mit Flagge Meiner Code-Ansicht zu suchen ist:Ich mag Flagge in meinem Land Dropdown

if (function_exists (! 'wcpbc_manual_country_script')) {

function wcpbc_manual_country_script() { 
    ?> 
    <script type="text/javascript"> 
     jQuery(document).ready(function($){ 
      $('.wcpbc-widget-country-selecting').on('change', 'select.country', function(){ 
       $(this).closest('form').submit(); 
      }); 
     });  
    </script> 
    <?php 
} 

}

add_action ('wp_print_footer_scripts', 'wcpbc_manual_country_script');

if ($ Länder):?>

<form method="post" class="wcpbc-widget-country-selecting">  
    <select class="country" name="wcpbc-manual-country"> 
     <?php foreach ($countries as $key => $value) : ?> 
      <option value="<?php echo $key?>" <?php echo selected($key, $selected_country); ?> ><?php echo $value; ?></option> 
     <?php endforeach; ?> 
    </select>     
</form>   

das Plugin Name ist: https://wordpress.org/plugins/woocommerce-product-price-based-on-countries/

+0

ist es eine Frage, dort irgendwo? – Todd

Antwort

0

Sie können ein Bild auf die Optionen in einem Auswahlelement nicht hinzufügen, aber Sie können dies mit jquery plugin: http://gregfranko.com/jquery.selectBoxIt.js/#IconsandImages

Sie müssen einschließen; - jquery.js - jquery-ui.js - selectBoxIt.js und - selectBoxIt.css

Wenn Sie eine Schleife durch jedes Land in der dropdown Sie verweisen müssen, dass die Länder Bild Flagge und es hinzufügen zum Attribut "data-iconurl" der Option.

<option value="country_value" data-iconurl="flag_image_url"> 

initialisieren Dann das Plugin:

$("select.country").selectBoxIt(); 

Beispiel: http://codepen.io/partypete25/pen/pNbpGP

Verwandte Themen