Skip to content

Instantly share code, notes, and snippets.

@rajakannan
rajakannan / returnException.php
Last active Feb 28, 2020
Return authentication exception for Laravel API 5.6
View returnException.php
<?php
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
{
@rajakannan
rajakannan / .zshrc
Created Feb 28, 2020
My ZSH settings
View .zshrc
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
@rajakannan
rajakannan / Woocommerce_remove_product_meta_action.php
Last active Dec 26, 2019
Remove or Hide product meta (SKU, categories and tags) from WooCommerce single product pages
View Woocommerce_remove_product_meta_action.php
/* Add this code at the bottom of your theme's function.php or in your plugin code */
/* Remove product meta */
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
@rajakannan
rajakannan / gv-copy-.js
Created Jan 7, 2016
Gravity Form copy form fields (Eg: same as billing address check box for shipping address )
View gv-copy-.js
function bindGformHandlers() {
//bind the click function
$(document).on('click', '.fill-check input', function() {
if($(this).is(':checked')) {
//put in the selectors we fill from
var fill_from = $('.fill-from, .fill-from .name_last, .fill-from .name_first');
fill_from.each(function() {
//get the label
@rajakannan
rajakannan / ubuntu-php-version-switch.md
Last active Nov 15, 2019
How can I downgrade from PHP 7 to PHP 5.6 on Ubuntu 16.04? / How to change php version in Ubuntu Apache
View ubuntu-php-version-switch.md

Switch PHP version:

Note: change PHP version numbers to match your requirement. I have used 5.6 and 7.0

From php5.6 to php7.0 :

Apache:

Changing php version for Aapche server

sudo a2dismod php5.6 ; sudo a2enmod php7.0 ; sudo service apache2 restart
@rajakannan
rajakannan / react-note.md
Last active Nov 15, 2019
React / React Native apk build release build and cache clear
View react-note.md

Clear bundle cache before release build

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/

Get a release build

cd android && ./gradlew assembleRelease && ../
@rajakannan
rajakannan / woocommerce.php
Last active Nov 15, 2019
Collection of essential snippets
View woocommerce.php
<?php
/**
* Display field value on the admin order edit page
*/
add_action( 'woocommerce_admin_order_data_after_billing_address', 'my_custom_checkout_field_display_admin_order_meta', 10, 1 );
function my_custom_checkout_field_display_admin_order_meta($order){
echo '<p><strong>'.__('My Field').':</strong> ' . get_post_meta( $order->id, 'My Field', true ) . '</p>';
}
View shipping-awd.php
<?php
/**
* Plugin Name: AWD Weight/State Shipping
* Plugin URI: http://www.andyswebdesign.ie/blog/free-woocommerce-weight-and-country-based-shipping-extension-plugin/
* Description: Weight and State based shipping method for Woocommerce.
* Version: 1.0.1
* Author: Andy_P (modified by Mantish to make it state based)
*/
/** Copyright 2012 andyswebdesign.ie
@rajakannan
rajakannan / Disable_PayPal_payment_method_in_the_checkout.php
Last active Nov 15, 2019
Disable PayPal payment method in the checkout
View Disable_PayPal_payment_method_in_the_checkout.php
<?php
/*
* Disable PayPal payment method in the checkout if certain
* products are present in the cart.
*
* Add this to your theme's functions.php file
*/
add_filter( 'woocommerce_available_payment_gateways', 'filter_gateways', 1);
function filter_gateways( $gateways ){
@rajakannan
rajakannan / WordPress-Utility.php
Created Jul 12, 2019
Most used wordpress custom codes
View WordPress-Utility.php
<?php
//////////////////////
// Custom Post Type //
//////////////////////
/*
* Creating a function to create our CPT tours
*/
You can’t perform that action at this time.