Skip to content

Instantly share code, notes, and snippets.

View kartick14's full-sized avatar
🎯
Focusing

Kartick Karmakar kartick14

🎯
Focusing
  • kolkata, India
View GitHub Profile
@kartick14
kartick14 / sqlq.php
Last active June 30, 2021 15:19
MySQL find exact substring from a string on DB table
$regxp = 'River';
$sql = "SELECT * FROM categories where catinclude RLIKE '(^|,)$regxp(,|\$)'";
@kartick14
kartick14 / index.html
Created November 3, 2021 11:04
Calculate percentage ratio on scroll ( with Jquery )
<div id="note" ></div>
<br><br><br><br><br><br><br><br><br><br><br>
<div class="scrollratio" ></div>
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>
<style>
body {
@kartick14
kartick14 / index.html
Created August 25, 2022 13:18
Custom scrolling animations - pausing sections and scrolling elements horizontally
https://stackoverflow.com/questions/56713668/custom-scrolling-animations-pausing-sections-and-scrolling-elements-horizontal
<script>
$('.nested').each(function() {
let $window = $(window), $body = $('body');
let $nested = $(this), $nestedPlaceholder = $nested.parent();
let verticalScrollRange, upperMargin, lowerMargin;
$window.resize(function(){
$nested.removeClass("sticky").css({left: 0});
let placeholderHeight = $nestedPlaceholder.css({height: ''}).height();
@kartick14
kartick14 / custom.js
Created March 21, 2023 10:31
Filter Image depends on alt tag value
const $img = jQuery(".product__media-list img");
jQuery(".color_input_fields input").on("click",function() {
$img.parents('li').hide();
const val = this.value.trim().toLowerCase();
if (val === "") return;
$img.filter(function() { return this.alt.toLowerCase().includes(val) }).parents('li').show()
});
@kartick14
kartick14 / functions.php
Created April 11, 2023 12:47
Woocommerce product customization with additional data passing
/* ------------------------- ADD TO CART section start --------------------- */
add_action('wp_ajax_nopriv_add_to_cart_ajax', 'add_to_cart_ajax_func');
add_action('wp_ajax_add_to_cart_ajax', 'add_to_cart_ajax_func');
function add_to_cart_ajax_func(){
//print_r($_POST);
$product_id = $_POST['product_id'];
$product_quantity = $_POST['product_quantity'];
$total_price = $_POST['total_price'];
@kartick14
kartick14 / functions.php
Last active September 25, 2024 13:47
create next previous post for custom post type
// create next previous page for custom post type
function get_prevnext_custompost($post_ID, $postType, $taxonomy, $term) {
if($taxonomy){
$args = array(
'post_type' => $postType,
'posts_per_page' => -1,
'post_status' => 'publish',
'tax_query' => array(
array(
'taxonomy' => $taxonomy,