Skip to content

Instantly share code, notes, and snippets.

@full-stack-king
full-stack-king / 0_reuse_code.js
Created June 6, 2014 04:02
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@full-stack-king
full-stack-king / Streetview_with_road_map_binded.html
Last active August 29, 2015 14:07
Displaying a road map on top of the street view and binding them
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps JavaScript API Example: Street View with Map</title>
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/standard.css" rel="stylesheet" type="text/css" />
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
<script type="text/javascript">
function initialize() {
<?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
@full-stack-king
full-stack-king / woocommerce.php
Last active November 15, 2019 04:00
Collection of essential snippets
<?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>';
}
@full-stack-king
full-stack-king / Disable_PayPal_payment_method_in_the_checkout.php
Last active November 15, 2019 03:59
Disable PayPal payment method in the checkout
<?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 ){
<?php
// Display Fields
add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' );
// Save Fields
add_action( 'woocommerce_process_product_meta', 'woo_add_custom_general_fields_save' );
function woo_add_custom_general_fields() {
@full-stack-king
full-stack-king / wc-product-meta-display.php
Created March 1, 2015 20:44
Here is a quick snippet to display WooCommerce product custom meta fields values (place it in functions.php):
<?php
/**
* WooCommerce Extra Feature
* --------------------------
*
* Display product meta field in a shortcode
* ex: [woo_custom_field id="my-custom-field"]
*
*/
function woo_custom_field_shortcode( $atts, $content = null ) {
@full-stack-king
full-stack-king / gformscopyaddress.js
Created January 7, 2016 16:04 — forked from tnorthcutt/gformscopyaddress.js
Autofill a set of fields (in a gravity form, in this case) based on a checkbox being checked.
jQuery(document).ready(function($) {
$('input#choice_13_1').click(function() {
if($(this).is(':checked')) {
$('#input_2_12_1').val($('#input_2_2_1').val());
$('#input_2_12_2').val($('#input_2_2_2').val());
$('#input_2_12_3').val($('#input_2_2_3').val());
$('#input_2_12_4').val($('#input_2_2_4').val());
$('#input_2_12_5').val($('#input_2_2_5').val());
};
});
@full-stack-king
full-stack-king / gv-copy-.js
Created January 7, 2016 16:06
Gravity Form copy form fields (Eg: same as billing address check box for shipping address )
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
@full-stack-king
full-stack-king / woocommerce-failed-order-email-notification.php
Created March 14, 2016 07:48
WooCommerce failed order email notification
<?php
/**
* Add a failed order email notification
*/
function sp_failed_order_email_notification( $order_id ) {
$order = wc_get_order( $order_id );
$to = get_option( 'admin_email' );
$subject = 'A order failed, action required';