28 July 2021

How to add to cart product with ajax in woocommerce?

Add to cart product with ajax in woocommerce (Without Refresh page).

<script>

jQuery(document).ready(function($) {

    $('.wishlist_add_to_cart').on('click', function(e){ 

    e.preventDefault();

$('.wishlist_preloader').css('visibility','visible');

    $thisbutton = $(this),

                $form = $thisbutton.closest('form.cart'),

                id = $thisbutton.val(),

                product_qty = $form.find('input[name=quantity]').val() || 1,

                product_id = $(this).data('product-id');

                variation_id = $form.find('input[name=variation_id]').val() || 0;

    var data = {

            action: 'ql_woocommerce_ajax_add_to_cart',

            product_id: product_id,

            product_sku: '',

            quantity: product_qty,

            variation_id: variation_id,

        };

    $.ajax({

            type: 'post',

            url: wc_add_to_cart_params.ajax_url,

            data: data,

            beforeSend: function (response) {

                $thisbutton.removeClass('added').addClass('loading');

            },

            complete: function (response) {

                $thisbutton.addClass('added').removeClass('loading');

            }, 

            success: function (response) {

                if (response.error & response.product_url) {

                    window.location = response.product_url;

                    return;

                } else { 

$('.delete_wishlist_'+ response).remove();

$('.wishlist_preloader').css('visibility','hidden');

$('.wishlist_notice_box').html('<div class="wishlist_notice_message">Product added to cart successfully.</div>');

get_wishlist_count();

                    $(document.body).trigger('added_to_cart', [response.fragments, response.cart_hash, $thisbutton]);

                } 

if (!$('tr').hasClass("wishlist_item")) {

$('.wp_wishlist_table tr:last').after('<tr><td colspan="6" >Not Found</td></tr>');

}

            }, 

        }); 

     }); 

});

</script> 


Paste in Function.php

add_action('wp_ajax_ql_woocommerce_ajax_add_to_cart', 'ql_woocommerce_ajax_add_to_cart'); 

add_action('wp_ajax_nopriv_ql_woocommerce_ajax_add_to_cart', 'ql_woocommerce_ajax_add_to_cart');  


function ql_woocommerce_ajax_add_to_cart() {  

    $product_id = apply_filters('ql_woocommerce_add_to_cart_product_id', absint($_POST['product_id']));

    $quantity = empty($_POST['quantity']) ? 1 : wc_stock_amount($_POST['quantity']);

    $variation_id = absint($_POST['variation_id']);

    $passed_validation = apply_filters('ql_woocommerce_add_to_cart_validation', true, $product_id, $quantity);

    $product_status = get_post_status($product_id); 

    if ($passed_validation && WC()->cart->add_to_cart($product_id, $quantity, $variation_id) && 'publish' === $product_status) { 

        do_action('ql_woocommerce_ajax_added_to_cart', $product_id);

            if ('yes' === get_option('ql_woocommerce_cart_redirect_after_add')) { 

                wc_add_to_cart_message(array($product_id => $quantity), true); 

            } 

echo $product_id;

           // WC_AJAX :: get_refreshed_fragments(); 

  

            } else { 

                $data = array( 

                    'error' => true,

                    'product_url' => apply_filters('ql_woocommerce_cart_redirect_after_error', get_permalink($product_id), $product_id));

                echo wp_send_json($data);

            }

            wp_die();

        }


How to get product detail from product id in woo-commerce?

Get product detail from product id in woo-commerce.


                $product_id = $result->post_id;
$product = wc_get_product( $product_id );
$product_link = get_permalink( $product->get_id() );

// Get Product ID
  
$product->get_id();
  
// Get Product General Info
  
$product->get_type();
$product->get_name();
$product->get_slug();
$product->get_date_created();
$product->get_date_modified();
$product->get_status();
$product->get_featured();
$product->get_catalog_visibility();
$product->get_description();
$product->get_short_description();
$product->get_sku();
$product->get_menu_order();
$product->get_virtual();
get_permalink( $product->get_id() );
  
// Get Product Prices
  
$product->get_price();
$product->get_regular_price();
$product->get_sale_price();
$product->get_date_on_sale_from();
$product->get_date_on_sale_to();
$product->get_total_sales();
  
// Get Product Tax, Shipping & Stock
  
$product->get_tax_status();
$product->get_tax_class();
$product->get_manage_stock();
$product->get_stock_quantity();
$product->get_stock_status();
$product->get_backorders();
$product->get_sold_individually();
$product->get_purchase_note();
$product->get_shipping_class_id();
  
// Get Product Dimensions
  
$product->get_weight();
$product->get_length();
$product->get_width();
$product->get_height();
$product->get_dimensions();
  
// Get Linked Products
  
$product->get_upsell_ids();
$product->get_cross_sell_ids();
$product->get_parent_id();
  
// Get Product Variations and Attributes
 
$product->get_children(); // get variations
$product->get_attributes();
$product->get_default_attributes();
$product->get_attribute( 'attributeid' ); //get specific attribute value
  
// Get Product Taxonomies
  
$product->get_categories();
$product->get_category_ids();
$product->get_tag_ids();
  
// Get Product Downloads
  
$product->get_downloads();
$product->get_download_expiry();
$product->get_downloadable();
$product->get_download_limit();
  
// Get Product Images
  
$product->get_image_id();
$product->get_image();
$product->get_gallery_image_ids();
  
// Get Product Reviews
  
$product->get_reviews_allowed();
$product->get_rating_counts();
$product->get_average_rating();
$product->get_review_count();

21 July 2021

How to add google reCAPTCHA in form in PHP?

Add google reCAPTCHA in form in PHP





<html>
<head>
  <script src='https://www.google.com/recaptcha/api.js' async defer></script>
</head>
<body>
<?php 
if(isset($_POST['submit'])){
$captcha;

        if(isset($_POST['g-recaptcha-response'])){
          $captcha=$_POST['g-recaptcha-response'];
        }
        if(!$captcha){
          echo 'Please check the the captcha form.';
          exit;
        }
        $secretKey = "<!==== Secret key ====!>";
        $ip = $_SERVER['REMOTE_ADDR'];
        // post request to server
        $url = 'https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($secretKey) .  '&response=' . urlencode($captcha);
        $response = file_get_contents($url);
        $responseKeys = json_decode($response,true);
        // should return JSON with success as true
        if($responseKeys["success"]) {
                echo 'Thanks for posting';
echo $_POST['name'];
        } else {
                echo 'You are spammer ! Get the @$%K out';
        }

}
?>
<form action="" method="post">
<input type="text" name="name" placeholder="name" value="Hello World">
<div class="g-recaptcha" data-sitekey="<!==== Site key ====!>"></div>
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>

How to make a section sticky in specific div (Section) in HTML/CSS?

Make a section sticky in specific div (Section) in HTML/CSS.






<style>
.scrollsec {
    height: fit-content;
    line-height: 50px;
    margin-top: 10px;
    font-size: 30px;
    padding-left: 10px;
    position: -webkit-sticky;
    position: sticky;
    top: 104px;
}
</style>

20 July 2021

How to create parallax effect in website?

Create parallax effect in website.





<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8"> 
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=500" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.8/ScrollMagic.js" integrity="sha512-UgS0SVyy/0fZ0i48Rr7gKpnP+Jio3oC7M4XaKP3BJUB/guN6Zr4BjU0Hsle0ey2HJvPLHE5YQCXTDrx27Lhe7A==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<style>

.section-wipes {
    height: 100%;
    width: 100%;
    background-image: none;
}
b {
    color: green;
    font-size: 44px;
    display: flex;
    margin: auto;
    align-items: center;
    justify-content: center;
    align-items: center;
}



body, html {
height: 100%;
padding: 0px;
margin: 0px;
}

.panel {
height: 100%;
width: 100%;
}


</style>
</head>
<body>


<body  class="section-wipes">
<section class="panel" style="background-color:blue">
<b>ONE</b>
</section>
<section class="panel " style="background-color:pink">
<b>TWO</b>
</section>
<section class="panel " style="background-color:green">
<b>THREE</b>
</section>
<section class="panel " style="background-color:red">
<b>FOUR</b>
</section>
<script>
$(function () { // wait for document ready
// init
var controller = new ScrollMagic.Controller({
globalSceneOptions: {
triggerHook: 'onLeave',
duration: "200%" // this works just fine with duration 0 as well
// However with large numbers (>20) of pinned sections display errors can occur so every section should be unpinned once it's covered by the next section.
// Normally 100% would work for this, but here 200% is used, as Panel 3 is shown for more than 100% of scrollheight due to the pause.
}
});

// get all slides
var slides = document.querySelectorAll("section.panel");

// create scene for every slide
for (var i=0; i<slides.length; i++) {
new ScrollMagic.Scene({
triggerElement: slides[i]
})
.setPin(slides[i], {pushFollowers: false})
.addIndicators() // add indicators (requires plugin)
.addTo(controller);
}
});
</script>
</body>


</body>
</html>

09 July 2021

How to create Sign-In profile and Sign-Out mini Drop-Down?

 function shortcut_menu(){

?>


<style>

.cus-dropbtn {

    color: black;

    padding: 16px;

    border: none;

    background: white !important;

    text-decoration: none !important;

    font-size: 15px !important;

    text-transform: capitalize;

}

.cus-dropdown {

    position: relative;

    display: inline-block;

    height: 32px;

}


.cus-dropdown-content {

    display: none;

    position: absolute;

    background-color: #f1f1f1;

    min-width: 160px;

    box-shadow: 0px 8px 16px 0px rgb(0 0 0 / 20%);

    z-index: 120;

    top: 33px;

}


.cus-dropdown-content a {

  color: black;

  padding: 12px 16px;

  text-decoration: none;

  display: block;

}


.cus-dropdown-content a:hover {background-color: #f1f1f1;}


.cus-dropdown:hover .cus-dropdown-content {display: block;}


.cus-dropdown:hover .cus-dropbtn {background-color: white;}



.cus-dropdown-content:after {

bottom: 100%;

left: 50%;

border: solid transparent;

content: "";

height: 0;

width: 0;

position: absolute;

pointer-events: none;

}




.cus-dropdown-content:after {

    border-color: rgba(213, 213, 213, 0);

    border-bottom-color: #d5d5d5;

    border-width: 9px;

    margin-left: -59px;

}


</style> 

</head>


<?php

global $current_user;

wp_get_current_user() ;

$username = $current_user->user_login;

$user_id = get_current_user_id();

$wcfmuser = wcfm_is_vendor( $user_id );

 if(wcfm_is_vendor( $user_id )){

$profile_url = site_url() . '/store-manager'; 

}

else{

$profile_url = site_url() . '/your-account';

}

 

if ( is_user_logged_in() ) {

?>

<div class="cus-dropdown">

  <a href="<?php echo site_url(); ?>/signin/" class="cus-dropbtn"><!--<i class="fas fa-user"></i> Hi ---><?php echo $username; ?></a>

  <div class="cus-dropdown-content">

    <a href="<?php echo $profile_url; ?>">Profile</a>

    <a href="<?php echo wp_logout_url( site_url() ); ?>">Sign Out</a>

  </div>

</div>

<?php

} else {

?>

<div class="cus-dropdown">

  <a href="<?php echo site_url(); ?>/signin/" class="cus-dropbtn"><i class="fas fa-user"></i> Sign In</a>

</div>

<?php

}

?>





<?php 

}

//add_action('wp_head', 'shortcut_menu'); 

add_shortcode('get_shortcut_menu', 'shortcut_menu'); 

03 July 2021

How to create custom product review section in woocommerce in WCFM?

Create custom  product review section in woocommerce in WCFM?





Paste in function.php

function fetch_vendor_product_reviews(){


// print_R($_POST);

$post_order_num = $_POST['post_order'];

$user_id = $_POST['store_id'];

$page = $_POST['page_num'];

if(empty($page)){

$page = 1;

}

if(empty($post_order_num) || $post_order_num == 1){

$post_order = 'DESC';

}

else{

$post_order = 'ASC';

}


if(!empty($user_id)){


$countreviews = get_comments(array(

'post_author'      => $user_id, 

        'status'   => 'approve',

        'post_status' => 'publish',

        'post_type'   => 'product',

        'count' => true

    ));

if($countreviews>0){

  ?>

<!-- filter section start -->

<section class="filter-home-product">

<div class="container">

<div class="row">

<div class="col-lg-3 col-md-3 col-sm-12">

<div class="write-review pull-left">

<span><?php echo $countreviews; ?> Reviews</span>

</div>

</div>

<div class="col-lg-9 col-md-9 col-sm-12">

<div class="write-review pull-left">

<span>Write a Review</span>

</div>

<div class="write-review pull-right">

<ul>

<li>

<div> 

<span>Sort By: </span>

<select name="price" class="post_order" id="price">

<option value="1" <?php if($post_order_num ==1){ echo 'selected'; } ?> >Newest</option>

<option value="2" <?php if($post_order_num ==2){ echo 'selected'; } ?>>Oldest</option>

</select> 

</div>

</li>

</ul>

</div>

</div>

</div>

<?php


$limit = 2;

$offset = ($page * $limit) - $limit;

$pages = ceil($countreviews/2);


$comment_args = array( 

                'post_author'      => $user_id, 

                'status'      => 'approve', 

                'post_status' => 'publish', 

                'post_type'   => 'product',

                'offset'   => $offset,

                'number'   => $limit,

'orderby'=> 'ID', 

'order'   => $post_order

        );

$comments = get_comments($comment_args);

//print_R($comments);

if ( ! $comments ) return '';

/* echo '<pre>';

print_R($comments); */

foreach ( $comments as $comment ) {  

//echo $comment->comment_author; 

$comment_post_ID =  $comment->comment_post_ID; 

$comment_user_id = $comment->user_id; 

$product = wc_get_product( $comment_post_ID );

// if($comment_user_id==$user_id){

// if(get_comment_author($comment->comment_post_ID)==$user_id){

$rating = intval( get_comment_meta( $comment->comment_ID, 'rating', true ) );

?>

<div class="row" style="margin-top:50px;">

<div class="col-lg-3 col-md-3 col-sm-12">

<div class="filter-product">

<div class="filter-author">

<i class="fa fa-user-circle"></i>

<h4><?php echo $comment->comment_author; ?></h4>

</div>

<div class="product-pics">

<?php  echo get_the_post_thumbnail($comment_post_ID); ?>

</div>

<div class="product-disc">

<h3><a href="<?php echo get_permalink( $comment_post_ID ); ?>"><?php echo $comment->post_title; ?></a></h3>

<p><?php echo get_woocommerce_currency_symbol() .''. $product->get_price(); ?></p>

</div>

</div>

</div>

<div class="col-lg-9 col-md-9 col-sm-12">

<div class="filter-product">

<div class="review-star text-center" style="text-align:left !important;">

<?php echo wc_get_rating_html( $rating ); ?>

<h3 style="font-weight:700;margin:20px 0 30px;">amazing!!</h3>

<p><?php echo $comment->comment_content; ?></p>

<div class="filter-product-btn">

<div class="write-review pull-left">

<p><i style="color:#387b50;" class="fa fa-check"></i>Recommends this project</p>

</div>

<div class="write-review pull-right">

<span>Did you find this helpful?</span>

<span class="up-down"><i class="fas fa-caret-up"></i>10</span>

<span class="up-down"><i class="fa fa-caret-down"></i>3</span>

</div>

</div>

</div>

</div>

</div>

</div>

<?php

}

?>

<div class="row">

<div class="col-lg-12 col-md-12 col-sm-12">

<div class="pagination-block">

<?php if($page != 1){

?>

<a class="next page-numbers" data-page="<?php echo $pages-1; ?>" href=""><i class="fas fa-angle-left" aria-hidden="true"></i></a>

<?php 

}

?>

<?php

if($pages != 1){

for($i=1; $i <= $pages; $i++)

{

?>

<span class="page-numbers <?php if($page==$i){ echo 'current'; } ?>" data-page="<?php echo $i; ?>" ><?php echo $i; ?></span>

<?php

}

}

?>

<?php if($page != $pages){

?>

<a class="next page-numbers" data-page="<?php echo $pages; ?>" href=""><i class="fas fa-angle-right" aria-hidden="true"></i></a>

<?php

}

?>

                       </div>

</div>

</div>

</div>

</section>


<?php

 }

 }


die();

}

add_action('wp_ajax_fetch_vendor_product_reviews','fetch_vendor_product_reviews');

add_action('wp_ajax_nopriv_fetch_vendor_product_reviews','fetch_vendor_product_reviews');






function vendor_product_reviews(){

global $WCFM, $WCFMmp, $wp, $WCFM_Query, $post;

$store_id = '';

if ( isset( $attr['id'] ) && !empty( $attr['id'] ) ) { $store_id = absint($attr['id']); }

if (  wcfm_is_store_page() ) {

$wcfm_store_url = get_option( 'wcfm_store_url', 'store' );

$store_name = apply_filters( 'wcfmmp_store_query_var', get_query_var( $wcfm_store_url ) );

$store_id  = 0;

if ( !empty( $store_name ) ) {

$store_user = get_user_by( 'slug', $store_name );

}

$store_id  = $store_user->ID;

}

?>

<!-- Bootstrap CSS -->


<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">

    <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/custom-css/bootstrap.min.css">

<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/custom-css/bootstyle.css">

<link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">

<div class="review_section_outer_box">

<div class="review_preloader">

<img src="<?php echo get_template_directory_uri(); ?>/assets/images/reivewloader.gif">

</div>

<div class="custom_review_box">

</div>

</div>


<script>

jQuery(document).ready(function($){

fetch_vendor_product_reviews(); 

$('body').on('change','.post_order',function(e){

e.preventDefault();

//$('.post_order').change(function(){

fetch_vendor_product_reviews(); 

});



$('body').on('click','.page-numbers',function(e){

e.preventDefault();

//$('.post_order').change(function(){

var page_num = $(this).data('page');

//alert(page_num);

fetch_vendor_product_reviews(page_num); 

});

 function fetch_vendor_product_reviews(page_num){

    var post_order = $('.post_order').val();

    var store_id = "<?php echo $store_id; ?>";

$('.review_preloader').css('display','flex')

var ajax =  "<?php echo admin_url('admin-ajax.php'); ?>";

    var data = {

'action' : "fetch_vendor_product_reviews",

'post_order' : post_order,

'store_id' : store_id,

'page_num' : page_num

    } 

    $.post(ajax,data,function(response){

//$("#response").html(response);

//console.log(response);

$('.custom_review_box').html(response);

$('.review_preloader').css('display','none')

    });

   }

    

});

</script>

<?php

 }

//add_action('wp_head','vendor_product_reviews');

add_shortcode('get_vendor_product_reviews', 'vendor_product_reviews'); 


Paste anywhere

<?php echo do_shortcode('[staff_detail]'); ?>



How to get store data from WCFM(Best Multi Vendor Marketplace) Plugin?

 Get store data from WCFM(Best Multi Vendor Marketplace) Plugin.


global $WCFM, $WCFMmp, $wp, $WCFM_Query, $post;

$store_id = '';

if ( isset( $attr['id'] ) && !empty( $attr['id'] ) ) { $store_id = absint($attr['id']); }

if (  wcfm_is_store_page() ) {

$wcfm_store_url = get_option( 'wcfm_store_url', 'store' );

$store_name = apply_filters( 'wcfmmp_store_query_var', get_query_var( $wcfm_store_url ) );

$store_id  = 0;

if ( !empty( $store_name ) ) {

$store_user = get_user_by( 'slug', $store_name );

}

$store_id    = $store_user->ID;

}

$user_id = $store_id; 

$vendor_data = get_user_meta( $user_id, 'wcfmmp_profile_settings', true );

$street_1 = $vendor_data['address']['street_1'];

$street_2 = $vendor_data['address']['street_2'];

$city     = $vendor_data['address']['city'];

$zip      = $vendor_data['address']['zip'];

$country  = $vendor_data['address']['country'];

$state    = $vendor_data['address']['state'];

$store_email    = $vendor_data['store_email'];

$phone    = $vendor_data['phone'];

$store_location    = $vendor_data['store_location'];

How to get review bar in Woo-commerce in wordpress.

Get review bar in Woo-commerce in wordpress.


 function get_all_products() {

    $ps = new WP_Query( array(
        'post_type' => 'product',
        'post_status' => 'publish',
'author' => 130,
        'posts_per_page' => '-1'
    ) );
    $arr = array();
    while($ps->have_posts()){
      $ps->the_post();
      $arr[] = get_the_ID();
    }
    return $arr;
}



function get_store_bar_rating(){
  $products = get_all_products();
  foreach ($products as $key => $value) {
$product_id = $value;
$get_rating_count = get_post_meta( $product_id, '_wc_rating_count', true );
   if(is_array($get_rating_count)){
foreach($get_rating_count as $key=>$value){
if($key==1){
$onerating += $value;
}
if($key==2){
$tworating += $value;
}
if($key==3){
$threerating += $value;
}
if($key==4){
$fourrating += $value;
}
if($key==5){
$fiverating += $value;
}
}
   } 
  }


if(empty($onerating)){
$onerating = 0;
}
if(empty($tworating)){
$tworating = 0;
}
if(empty($threerating)){
$threerating = 0;
}
if(empty($fourrating)){
$fourrating = 0;
}
if(empty($fiverating)){
$fiverating = 0;
}

$totalrating = $onerating + $tworating + $threerating + $fourrating + $fiverating;

/*    echo '1 =' . $onerating;
   echo '<br>';
   echo '2 =' . $tworating;
   echo '<br>';
   echo '3 =' . $threerating;
   echo '<br>';
   echo '4 =' . $fourrating;
   echo '<br>';
   echo '5 =' . $fiverating;
   echo '<br>'; */
$onewidth   = $onerating * 100 / $totalrating;
$twowidth   = $tworating * 100 / $totalrating;
$threewidth = $threerating * 100 / $totalrating;
$fourwidth  = $fourrating * 100 / $totalrating;
$fivewidth  = $fiverating * 100 / $totalrating;
   
?>
<style>

.review_box_con{

}
.review_row{
  display : flex;
  margin-bottom:20px
}
.outer_review_bar{
  width:100%;
  height:30px;
  background:#f1f1f1;
  margin-left : 70px;
  overflow:hidden;
}
.inner_review_bar{
  height:30px;
  background:#F6C1B8;
}
.review_star_tx {
    font-size: 20px;
    font-weight: 500;
    display: inline-block;
    width: 87px;
    text-align: center;
    line-height: 28px;
}
span.total_bar_rating {
    font-size: 21px;
    font-weight: 700;
    margin-bottom: 9px;
    box-sizing: border-box;
    display: inline-block;
}
</style>
<div class="review_box_con">
<span class="total_bar_rating"><?php if(empty($totalrating)){ echo '0'; }else { echo $totalrating; } ?> reviews</span> 
    <div class="review_row">
      <span class="review_star_tx">5 Star</span>
    <div class="outer_review_bar">
      <div class="inner_review_bar" style="width:<?php if(!empty($fivewidth)){ echo $fivewidth .'%'; }else { echo '0'; } ?>">
      </div>      
    </div>
    <span class="review_star_tx" ><?php if(empty($fiverating)){ echo '0'; }else { echo $fiverating; } ?></span>
    </div>
      <div class="review_row">
      <span class="review_star_tx">4 Star</span>
    <div class="outer_review_bar">
       <div class="inner_review_bar"  style="width:<?php if(!empty($fourwidth)){ echo $fourwidth .'%'; }else { echo '0'; } ?>">
      </div>      
    </div>
    <span class="review_star_tx" ><?php if(empty($fourrating)){ echo '0'; }else { echo $fourrating; } ?></span>
    </div>
      <div class="review_row">
      <span class="review_star_tx">3 Star</span>
    <div class="outer_review_bar">
       <div class="inner_review_bar"  style="width:<?php if(!empty($threewidth)){ echo $threewidth .'%'; }else { echo '0'; } ?>">
      </div>      
    </div>
    <span class="review_star_tx" ><?php if(empty($threerating)){ echo '0'; }else { echo $threerating; } ?></span>
    </div>
      <div class="review_row">
      <span class="review_star_tx">2 Star</span>
    <div class="outer_review_bar">
       <div class="inner_review_bar"  style="width:<?php if(!empty($twowidth)){ echo $twowidth .'%'; }else { echo '0'; } ?>">
      </div>      
    </div>
    <span class="review_star_tx" ><?php if(empty($tworating)){ echo '0'; }else { echo $tworating; } ?></span>
    </div>
      <div class="review_row"> 
      <span class="review_star_tx">1 Star</span>
    <div class="outer_review_bar">
       <div class="inner_review_bar"  style="width:<?php if(!empty($onewidth)){ echo $onewidth .'%'; }else { echo '0'; } ?>">
      </div>      
    </div>
    <span class="review_star_tx" ><?php if(empty($onerating)){ echo '0'; }else { echo $onerating; } ?></span>
    </div>
  
</div>

<?php
 }
add_shortcode('store_bar_rating', 'get_store_bar_rating'); 
 
 

User it anywhere

<?php echo do_shortcode('[store_bar_rating]'); ?>
 

How to add re-captcha v3 on all Elementor forms using coding?

 Add re-captcha v3 on all Elementor forms using coding add_action('wp_footer',function(){     ?> <script src="https://www...