Skip to main content

Posts

Showing posts from 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' );

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

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 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-lef

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"&g

How to enqueue script and css file in child-theme and main plugin file in worpress?

enqueue script and css file in child-theme or main plugin file in worpress FOR Child theme function theme_js() { wp_enqueue_script( 'theme_js', get_stylesheet_directory_uri() . '/js/custom.js', array( 'jquery' )); } add_action('wp_enqueue_scripts', 'theme_js'); FOR main plugin file  function ecom_scripts(){ wp_enqueue_script("jquery"); wp_enqueue_script( 'foundation-script', plugins_url('/slider/foundation.min.js', __FILE__)); wp_enqueue_script( 'slick-script', plugins_url('/slider/slick.min.js', __FILE__)); // wp_enqueue_style( 'foundation-style', plugins_url('/slider/foundation.css', __FILE__)); wp_enqueue_style( 'slick-style', plugins_url('/slider/slick.css', __FILE__));      wp_enqueue_script( 'ecom-script', plugins_url('/js/custom.js', __FILE__)); wp_localize_script( 'ecom-script', 'myajax', array( &#

How to get next 7 days from current day in php ?

Get next 7 days from current day in php  global $wpdb; global $wpsite; $cd = date('d-m-Y'); $nd = date('d-m-Y', strtotime("$cd +".$oid." day")); $begin = new DateTime($cd); $end = new DateTime($nd); $interval = DateInterval::createFromDateString('1 day'); $period = new DatePeriod($begin, $interval, $end); $i = 1; foreach ($period as $dt) { $dt->format("D d-m-Y"); $day = $dt->format("D"); $daynum = $dt->format("d"); echo '<div><span>'.$daynum.' '.$day.'</span></div>'; $i++; }