• <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    
      <div class="box1">
      <div class="sel_title"> <select id="facebook">
      <option value="" label="">Facebook</option>
        <?php
    	 $args = array( 'post_type' => 'product', 'product_cat' => 'facebook');
            $loop = new WP_Query( $args );
           while ( $loop->have_posts() ) : $loop->the_post(); global $product;?>
    
         <option value="<?php echo $product->get_price_html(); ?>"  label="<?php echo $product->id;?>"> <?php the_title(); ?></option>
            <?php endwhile; ?>
       </select></div>
        <div class="sel_prize"><input type="text" name="prize"  id="facebook_prize"/></div>
    	<div class="sel_adcart"><span id="fb_but"></span></div>
         <?php wp_reset_query(); ?>
         </div>
    
    <script>
    $("#facebook").on('change', function(){
    if($('option:selected', this).attr('label') != ""){
    	$("#fb_but").html("<a title='Add to cart' rel='nofollow'></a>")
    }
    else{
    	$("#fb_but").html('');
    }
       $('#facebook_prize').val(this.value);
    });
    
    </script>

    [Moderator Note: Please post code or markup between backticks or use the code button. Or better still – use a pastebin. Your posted code may now have been permanently damaged by the forum’s parser.]

    https://www.ads-software.com/plugins/woocommerce/

  • The topic ‘product in Dropdown(Selcect box) by Caregory Name WooCommerce’ is closed to new replies.