28 October 2019

How to use PHP explode() Function (After comma)?

How to use PHP explode() Function (After comma)?

<html>
<body>

<?php
$str = "Hello,bro,how,are,you,what,are,you,doing";
print_r (explode(",",$str));
?>

</body>
</html>

16 October 2019

How to get woocommerce products in loop ?

get woocommerce products in loop 
with shortcode

function crousalproducts(){



?>
<ul class="products">
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => 12
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post();
wc_get_template_part( 'content', 'product' );
endwhile;
} else {
echo __( 'No products found' );
}
wp_reset_postdata();
?>
</ul><!--/.products-->
<?php


}
add_shortcode( 'crousal', 'crousalproducts' );

12 October 2019

How to Update Custom Cart Count (or any HTML) after AJAX Add to Cart in WooCommerce

 Update Custom Cart Count (or any HTML) after AJAX Add to Cart in WooCommerce






function totalcartqty(){


?>
<div class="header-cart-count"><?php echo WC()->cart->get_cart_contents_count(); ?></div>
<?php
}

add_action('wp_head','totalcartqty');

add_filter( 'woocommerce_add_to_cart_fragments', 'iconic_cart_count_fragments', 10, 1 );

function iconic_cart_count_fragments( $fragments ) {
   
    $fragments['div.header-cart-count'] = '<div class="header-cart-count">' . WC()->cart->get_cart_contents_count() . '</div>';
   
    return $fragments;
   
}

How to remove the product rating display on product loops in woocommerce?




// Remove the product rating display on product loops



remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 );

10 October 2019

How to choose two dates (date range) from text field?

Choose two dates (date range) from text field




<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery-date-range-picker/0.20.0/jquery.daterangepicker.min.js'></script>
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/jquery-date-range-picker/0.20.0/daterangepicker.min.css'>

<script type="text/javascript">
$(document).ready(function() {
  $('#date-range-filter').dateRangePicker({
    format: 'DD/MM/YYYY',
    getValue: function() {
      if ( $('#date-from').val() && $('#date-to').val() ) {
        return $('#date-from').val() + ' to ' + $('#date-to').val();
      }
      else {
        return '';
      }
    },
    setValue: function(daterangepicker, from, to) {
      $('#date-from').val(from);
      $('#date-to').val(to);
    }
  });
});
</script>



</head>
<body>
<form action="" method="post">
<span id='date-range-filter'>
  From: <input id='date-from'>
  To: <input id='date-to'>
</span>
<input type="submit" name="submit" value="Submit">
<form>
</body>
</html>

How to pick date(Date Picker) from text field with placeholder in jquery?

 pick date(Date Picker)  from text field with placeholder in jquery




<html>
<head>

  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script>
  $( function() {
    $( "#datepicker" ).datepicker({ dateFormat: "dd-mm-yy" });
  } );
  </script>
</head>
<body>

<p>Date: <input type="text" id="datepicker" placeholder="Choose date"></p>


</body>
</html>

How to use jquery on checkbox in worpdress ?

<html lang="en">
<head>
<meta charset="utf-8">
<title>Check the Status of Checkboxes</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $('input[type="checkbox"]').click(function(){
            if($(this).is(":checked")){
                alert("Checkbox is checked.");
            }
            else if($(this).is(":not(:checked)")){
                alert("Checkbox is unchecked.");
            }
        });
    });
</script>
</head>
<body>
    <p><input type="checkbox"> Check or uncheck the checkbox to get the status.</p>
</body>
</html>

How to create video slider with cuncks of videos without download all videos?

 Create video slider with cuncks of videos without download all videos function custom_video_slider_shortcode() { $slider_id = 'vide...