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 / function.php
Created April 30, 2018 09:42
Enable/Disable Payment Gateway for a Specific User Role
/**
* @snippet Enable Payment Gateway for a Specific User Role | WooCommerce
*/
function custom_paypal_enable_manager( $available_gateways ) {
global $woocommerce;
if ( isset( $available_gateways['paypal'] ) && !current_user_can('shop_manager') ) {
unset( $available_gateways['paypal'] );
}
return $available_gateways;
@kartick14
kartick14 / cart.liquid
Created April 23, 2018 12:43
Product details for wholesaler with each variant added to cart
<div class="page-width" data-section-id="{{ section.id }}" data-section-type="cart-template">
{% if cart.item_count > 0 %}
<div class="section-header text-center">
<h1>{{ 'cart.general.title' | t }}</h1>
</div>
<form action="/cart" method="post" novalidate class="cart">
{% if customer.tags contains 'wholesaler' %}
{% for custag in customer.tags %}
@kartick14
kartick14 / cart.liquid
Last active March 27, 2025 06:53
Apply discount code from cart page in shopify
<div class="discountcodefield">
<label for="discount">Discount Code:</label>
<input autocomplete="off" type="hidden" name="discount" class="discount_code" />
<input autocomplete="off" type="text" name="discount_code" class="discount_code_field" />
<input type="button" name="apply_discount_code" class="btn discount_code_btn" value="Apply"/>
</div>
<div class="cart__savings discount_apply_code">
</div>
@kartick14
kartick14 / function.js
Created April 19, 2018 08:20
Use event delegation for dynamically created elements: When element create after ajax success
$(document).on("click", '.mylink', function(event) {
alert("new link clicked!");
});
@kartick14
kartick14 / index.html
Created March 20, 2018 14:54
Track HTML5 Video life
<video src="video.ogv" id="myVideo">
video not supported
</video>
<script type='text/javascript'>
document.getElementById('myVideo').addEventListener('ended',myHandler,false);
function myHandler(e) {
// What you want to do after the event
}
</script>
@kartick14
kartick14 / wp-query-ref.php
Created February 13, 2018 05:43 — forked from luetkemj/wp-query-ref.php
WP: Query $args
// This gist is now maintained on github at https://github.com/luetkemj/wp-query-ref
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.github.io
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/4.9.4/src/wp-includes/query.php
*/