Skip to content

Instantly share code, notes, and snippets.

View kish2011's full-sized avatar
🏠
Working from home

Kishore Chandra Sahoo kish2011

🏠
Working from home
View GitHub Profile
@kish2011
kish2011 / send.php
Last active September 23, 2019 17:00
Sending message to RabbitMQ
<?php
require_once __DIR__ . '/vendor/autoload.php';
use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;
$connection = new AMQPStreamConnection('localhost', 5672, 'guest', 'guest');
$channel = $connection->channel();
$channel->queue_declare('hello', false, false, false, false);
@kish2011
kish2011 / adding_new_webhook_topics.php
Created August 27, 2019 18:06 — forked from jessepearson/adding_new_webhook_topics.php
How to add a new custom Webhook topic in WooCommerce, with example of order filtering.
<?php // do not copy this line
/**
* add_new_topic_hooks will add a new webhook topic hook.
* @param array $topic_hooks Esxisting topic hooks.
*/
function add_new_topic_hooks( $topic_hooks ) {
// Array that has the topic as resource.event with arrays of actions that call that topic.
@kish2011
kish2011 / add-to-cart.php
Created August 16, 2019 11:20 — forked from lukecav/add-to-cart.php
Display Product Variations in the Shop Loop - With Conditional Apply Filter Logic
<?php
/**
* Custom Loop Add to Cart.
*
* Template with quantity and ajax.
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
global $product;
@kish2011
kish2011 / wc-hide-coupons-cart-checkout.php
Created August 16, 2019 08:45 — forked from maxrice/wc-hide-coupons-cart-checkout.php
WooCommerce - hide the coupon form on the cart or checkout page, but leave coupons enabled for use with plugins like Smart Coupons and URL Coupons
<?php
// hide coupon field on cart page
function hide_coupon_field_on_cart( $enabled ) {
if ( is_cart() ) {
$enabled = false;
}
return $enabled;
@kish2011
kish2011 / coupon-lists.php
Created August 15, 2019 17:52
Display coupon name in cart page
add_action('woocommerce_cart_coupon', 'woocommerce_cart_coupon_list');
function woocommerce_cart_coupon_list() {
$args = array(
'posts_per_page' => 5,
'orderby' => 'title',
'order' => 'desc',
'post_type' => 'shop_coupon',
'post_status' => 'publish',
);
@kish2011
kish2011 / wc-auto-restore-stock.php
Last active July 28, 2019 08:01
WC Auto Restore Stock
add_action( 'woocommerce_order_status_processing_to_cancelled', 'restore_order_stock', 10, 1 );
add_action( 'woocommerce_order_status_completed_to_cancelled', 'restore_order_stock', 10, 1 );
add_action( 'woocommerce_order_status_on-hold_to_cancelled', 'restore_order_stock', 10, 1 );
add_action( 'woocommerce_order_status_processing_to_refunded', 'restore_order_stock', 10, 1 );
add_action( 'woocommerce_order_status_completed_to_refunded', 'restore_order_stock', 10, 1 );
add_action( 'woocommerce_order_status_on-hold_to_refunded', 'restore_order_stock', 10, 1 );
function restore_order_stock( $order_id ) {
$order = new WC_Order( $order_id );
@kish2011
kish2011 / hg-commands.md
Created June 9, 2019 10:45 — forked from cortesben/hg-commands.md
Mercurial command cheat sheet

Mercurial Commands

Commands Description
hg pull get latest changes like git pull use flags like -u IDK why yet
hg add only for new files
hg commit add changes to commit with -m for message just like git
hg addremove adds new files and removes file not in your file system
hg incoming see changes commited by others
hg outgoing see local commits
@kish2011
kish2011 / rabbitmq-server.monit
Created April 27, 2019 18:00 — forked from tuantm8/rabbitmq-server.monit
Monit configuration for rabbitmq-server
check process rabbitmq-server matching "/usr/lib/erlang/erts-6.2/bin/beam"
group rabbitmq
start program = "/etc/init.d/rabbitmq-server start"
stop program = "/etc/init.d/rabbitmq-server stop"
if failed port 5672 type tcp then restart
if 3 restarts within 3 cycles then timeout
<?php
/**
* Plugin Name: WP Minions Post Pusher
* Description: Pushes all published posts to one blog using wp-minions
* Version: 1.0
* Author: Thorsten ott
* Author URI: http://thorsten-ott.de/
* License: GPLv2 or later
*/
@kish2011
kish2011 / installing_supervisor_macosx.md
Created March 22, 2019 11:35 — forked from fadhlirahim/installing_supervisor_macosx.md
Setting up supervisord in Mac OS X

Installation

Installing Supervisor on OS X is simple:

sudo pip install supervisor

This assumes you have pip. If you don't: