Skip to content

Instantly share code, notes, and snippets.

View conschneider's full-sized avatar
🐼
Relax. Nothing is under control.

Con Schneider conschneider

🐼
Relax. Nothing is under control.
View GitHub Profile
@conschneider
conschneider / Create lookup tables and order stats manually for WooCommerce 4.sql
Last active June 7, 2022 08:38
Please note the wp_ prefix and change accordingly if needed! Also check the table names so you don't drop data of tables already there!
/*
* Please note the wp_ prefix and change accordingly if needed!
* Also check the table names so you don't drop data of tables already there!
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for wp_wc_customer_lookup
add_filter( 'woocommerce_admin_disabled', '__return_true' );
@conschneider
conschneider / Create WooCommerce Admin tables for WooCommerce 4 manually.sql
Last active March 19, 2020 13:52
This SQL command creates the WooCommerce Admin tables for WooCommerce 4 manually.
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for wp_wc_admin_note_actions
-- INFO: This uses the prefix wp_ - change accordingly.
-- ----------------------------
DROP TABLE IF EXISTS `wp_wc_admin_note_actions`;
CREATE TABLE `wp_wc_admin_note_actions` (
`action_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
@conschneider
conschneider / Create Action Scheduler 3.1 tables for WooCommerce 4 manually.sql
Last active May 14, 2023 18:46
This SQL command creates the Action Action Scheduler 3 tables for WooCommerce 4 manually.
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for wp_actionscheduler_actions
-- INFO: This uses the prefix wp_ - change accordingly.
-- ----------------------------
DROP TABLE IF EXISTS `wp_actionscheduler_actions`;
CREATE TABLE `wp_actionscheduler_actions` (
`action_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
.page-template-template-homepage .type-page {padding-top:0;padding-bottom:0;}
.hentry{margin:0;}
.page-template-template-homepage:not(.has-post-thumbnail) .site-main {padding-top:0;}
@conschneider
conschneider / Sendy-nginx-configuration
Created October 12, 2019 15:20
Nginx configuration for Sendy newsletter application. You can replace /sendy with / if you run it out of the root of a (sub)domain.
location /sendy {
access_log off;
error_log off;
rewrite ^/sendy/(l|t|w)/([a-zA-Z0-9\/]+)$ /sendy/$1.php?i=$2&$args;
rewrite ^/sendy/(u?n?subscribe)/(.*)$ /sendy/$1.php?i=$2&$args;
try_files $uri $uri/ $uri.php?$args;
}
@conschneider
conschneider / Search PHP array of objects by property value to find specifc object instance..php
Created August 15, 2019 14:07
Search through an array of objects by defined property value. Returns object.
<?php
$array = [
(object)['ID' => 420, 'name' => "Mary"],
(object)['ID' => 10957, 'name' => "Blah"],
];
$v=10957;
$entry = current(array_filter($array, function($e) use($v) { return $e->ID==$v; }));
@conschneider
conschneider / woocommerce-email-new-address.php
Created July 23, 2019 06:59 — forked from BFTrick/woocommerce-email-new-address.php
Email the site admin when a customer changes their address
<?php
/**
* Plugin Name: WooCommerce Email Customer Address
* Plugin URI: https://gist.github.com/BFTrick/7891074
* Description: Email the site admin when a customer changes their address
* Author: Patrick Rauland
* Author URI: http://patrickrauland.com/
* Version: 1.0.1
*
* This program is free software: you can redistribute it and/or modify
<?php
/*
Plugin Name: Testing Code
Description: This is just a test plugin for some actions and filters.
Version: 0.1
Author: Con
*/
/**
* Security measure to prevent direct access.
@conschneider
conschneider / functions.php
Created July 9, 2019 17:24 — forked from gnikolopoulos/functions.php
[Woocommerce] Rule Based add-to-cart functions
/**
* Gets Variation ID if available otherwise it will get the Product ID
* @param $product Product
* @param bool $check_variations Whether or not to check for variation IDs
* @return mixed
*/
function get_id_from_product( $product, $check_variations = false ) {
if( $check_variations ) {
return ( isset( $product['variation_id'] )
&& ! empty( $product['variation_id'])