Categories
Uncategorized

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>

Categories
Uncategorized

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’ );

Categories
Uncategorized

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;
   
}

Categories
Uncategorized

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 );

Categories
Uncategorized

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>

Categories
Uncategorized

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>

Categories
Uncategorized

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>
Categories
Uncategorized

How to create vertical hamburger menu in wordpress?(Collabse Menu)

create vertical hamburger menu in wordpress?(Collabse Menu)

<html>
<head>
<style>
header#masthead {
    display: none;
}
footer#colophon {
    display: none;
}
.leftside {
    background-color: red;
    width: 20%;
    height: 100vh;
    position: absolute;
    z-index: 1;
    top: 0%;
    bottom: 0%;
    left: -20%;
}
.mainbox{
width:100%;
height:100vh;
background-color:blue;
display:flex;
align-item:center;
justify-content:center;
position:absolute;

}
.innerbox{
border:2px solid black;
width:95%;
height:95vh;
margin:auto;
position:relative;


}
input.bottonleft {
    color: wheat;
    background: #31a529;
    position: absolute;
    top: 0;
    left: 0;
margin:10px;

}
input.bottonx {
    color: wheat;
    background: #8c6767;
    position: absolute;
    top: 0;
    right: 0;
    margin: 12px;
    margin-top: 30px;
}

.blue{

left:0%;
transition:all 0.8s;

}

.green{

padding-left:20%;
transition:all 0.8s;

}
.pink{

left:-20%;
transition:all 0.8s;


}

.yellow{

padding-left: 0%;
transition:all 0.8s;

}

</style>
<script src=”https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js”></script>

<script>
$(document).ready(function(){
  $(“.bottonleft”).click(function(){
$(“.leftside”).addClass(“blue”);
$(“.mainbox”).addClass(“green”);
  $(“.leftside”).removeClass(“pink”);
  $(“.mainbox”).removeClass(“yellow”)
  });

  $(“.bottonx”).click(function(){
$(“.leftside”).addClass(“pink”);
$(“.mainbox”).addClass(“yellow”);
  $(“.leftside”).removeClass(“green”);
  $(“.mainbox”).removeClass(“blue”);

  });
  });

</script>
</head>
<body>
<div class=”leftside”>
<input type=”button” name=”buttonx” class=”bottonx” value=”X”></div>
<div class=”mainbox”>
<div class=”innerbox”>
<input type=”button” name=”button” class=”bottonleft” value=”>”>

</div>
</div>
</body>
</html>

Categories
Uncategorized

How to get last id from sql database in wordpress ?

 get last id from sql database 

After insert code

$lastid = $wpdb->insert_id;

Categories
Uncategorized

How to use properly search ajax in wordpress?

use properly search ajax in wordpress


Use in html file 

<html>
<head>

<style>
.sec {
    width: 223px;
    height: 41px;
    border: 1px solid #54595f;
margin-bottom:4px;
}
</style>
<script src=”<?php echo plugin_dir_url(__FILE__);?>js/jquery.min.js” type=”text/javascript”></script>
<script>
jQuery(document).ready(function($){
$(“.filter”).bind(“keyup change”, function() {


var ajaxurl = $(“.ajaxurl”).val();
var bylocation = $(“#by-search”).val();

var data = {
‘action’: ‘showloactions’,
‘bylocation’: bylocation,
};

jQuery.post(ajaxurl, data, function(response) {
$(“.wrapper”).html(response);
console.log(response);

});
});
});
</script>
</head>
<body>
<form action=”” method=”post”>
<input type=”text” name=”search” class=”filter” id=”by-search”>
<input type=”hidden” class=”ajaxurl” value=”<?php echo admin_url( ‘admin-ajax.php’ ) ;?>”>

</form>
<div class=”wrapper”>

</div>
<?php
//showloactions();

      ?>
</body>
</html>

Use in main plugin file 

 function showloactions(){

 $bylocation = $_POST[‘bylocation’];
 if(!$bylocation == “”){
        global $wpdb;
        global $wpsite;
$lacationtable = $wpdb->prefix.$wpsite.”_locations”;
        $result = $wpdb->get_results ( “SELECT * FROM $lacationtable where address LIKE ‘%$bylocation%'” );
        foreach ( $result as $print )   {
         
?>
<div class=”sec”><?php echo $print->city; ?></div>
            <?php
}
}
else{

echo “Not Found”;

}

die();

}
add_action(‘wp_ajax_showloactions’, ‘showloactions’);
add_action(‘wp_ajax_nopriv_showloactions’, ‘showloactions’);