Skip to main content

Posts

Showing posts from 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

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-

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"]) {      

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>

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:

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;

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=&

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&#

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