Skip to content

Instantly share code, notes, and snippets.

View kilbot's full-sized avatar

Paul Kilmurray kilbot

View GitHub Profile
@kilbot
kilbot / travis-ci-apache
Created June 14, 2015 23:30
travis-ci-apache
<VirtualHost *:80>
DocumentRoot %TRAVIS_BUILD_DIR%
<Directory "%TRAVIS_BUILD_DIR%">
Options FollowSymLinks MultiViews ExecCGI
AllowOverride All
Order deny,allow
Allow from all
</Directory>
@kilbot
kilbot / 22.json
Created June 25, 2015 14:17
WC Variable product
{
"product": {
"title": "Ship Your Idea",
"id": 22,
"created_at": "2013-06-07T10:46:01Z",
"updated_at": "2015-06-25T06:48:13Z",
"type": "variable",
"status": "publish",
"downloadable": false,
"virtual": false,
@kilbot
kilbot / order.json
Last active August 29, 2015 14:24
Example Order from WC REST API
{
"order": {
"id": 645,
"order_number": 645,
"created_at": "2015-01-26T20:00:21Z",
"updated_at": "2015-01-26T20:00:21Z",
"completed_at": "2015-01-26T20:00:21Z",
"status": "completed",
"currency": "USD",
"total": "79.87",
@kilbot
kilbot / functions.php
Last active August 29, 2017 06:19
Custom barcode example for WooCommerce POS
<?php
// this would go in your theme functions.php file
/**
* Custom product meta field to use as barcode
*
* By default WooCommerce POS will use the SKU field- '_sku'
* You can change the meta key using the following WordPress filter
*
@kilbot
kilbot / functions.php
Last active October 8, 2015 05:23
Hook to access product meta on order creation
function custom_order_item_meta_hook( $meta_id, $order_item_id, $meta_key, $meta_value ){
if( $meta_key == 'Delivery Date' ){
// Do something
}
}
add_action( 'added_order_item_meta', 'custom_order_item_meta_hook', 10, 4 );
@kilbot
kilbot / functions.php
Last active April 29, 2018 05:17
Example of removing the support menu item from WooCommerce POS for non super admins
<?php
// place this in your theme functions.php file
function my_custom_pos_menu($menu){
if( is_super_admin() ){
return $menu;
}
foreach($menu as $key => $item){
if($item['id'] == 'support')
@kilbot
kilbot / relevanssi.php
Created February 16, 2016 00:01
Remove Relevanssi
// remove relevanssi
remove_filter('posts_request', 'relevanssi_prevent_default_request');
remove_filter('the_posts', 'relevanssi_query');
@kilbot
kilbot / index.html
Last active February 29, 2016 06:14
Repro Safari IndexedDB autoIncrement bug
<body>
<h1>Repro Safari IndexedDB autoIncrement bug</h1>
<div id="logger"></div>
<script>
var dbname = 'time_' + Date.now() + '_';
function log(msg) {
document.getElementById("logger").innerHTML += msg + "<br>";
}
@kilbot
kilbot / functions.php
Last active July 1, 2016 02:56
Adding product meta during checkout
add_action('woocommerce_order_add_product', 'my_custom_product_meta');
function my_custom_product_meta($id, $item_id, $product) {
wc_add_order_item_meta($item_id, 'serial', $product->get_sku());
}
<?php
$conn = new mysqli($WORDPRESS_DB_HOST, $WORDPRESS_DB_USER, $WORDPRESS_DB_PASSWORD);
if(!mysqli_select_db($conn , $WORDPRESS_TESTS_DB_NAME)){
$sql = "CREATE DATABASE $WORDPRESS_TESTS_DB_NAME";
if ($conn->query($sql) === TRUE) {
echo "Database created successfully";
} else {
echo "Error creating database: " . $conn->error;
}