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 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,
@conschneider
conschneider / Create WooCommerce Blocks tables manually.sql
Last active March 9, 2023 18:26
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_reserved_stock
@conschneider
conschneider / filter-new-woo-order-mail-shipping-zone.php
Created February 16, 2023 16:10
Filter mail recipient of WooCommerce new order mail based on shipping zone.
add_filter( 'woocommerce_email_recipient_new_order', 'custom_new_order_recipient', 10, 2 );
function custom_new_order_recipient( $recipient, $order ) {
$shipping_zone = WC_Shipping_Zones::get_zone_matching_package( $order->get_shipping_packages() );
if ( $shipping_zone ) {
$zone_id = $shipping_zone->get_id();
// You can add more conditions to match specific shipping zones here
if ( $zone_id == 1 ) {
$recipient .= ', john@example.com';
} elseif ( $zone_id == 2 ) {
@conschneider
conschneider / woocommerce-pdf-voucher-custom-filename.php
Created November 5, 2017 13:33
Change WooCommerce PDF Voucher string to custom name
<?php //only copy if needed
//filter documented at: https://docs.woocommerce.com/document/woocommerce-pdf-product-vouchers-developer-documentation/#wc_pdf_product_vouchers_voucher_filename
add_filter('wc_pdf_product_vouchers_voucher_filename', 'cs_my_own_filename');
function cs_my_own_filename ($filename) {
// This is how the variable is defined: $filename = 'voucher-' . sanitize_file_name( $this->get_voucher_number() ) . '.' . $type;
// Note: $type may be defined as string. Default $type = 'pdf';
// Note: Do not use this filter to change the number. There are other filters for that.
@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
@conschneider
conschneider / wp-check-if-post-has-custom-taxonomy
Created September 27, 2017 18:30
WordPress check if post has custom taxonomy
<?php
// use of function has_term( 'slug', 'taxonomy_name', $post->ID );
// taxonomy_name for example: Visibility
// slug for example: visible
// $post->ID = current post
$terms = has_term( 'intern', 'artikel_typ', $post->ID );
if($terms)
{
777 Brockton Avenue, Abington MA 2351
30 Memorial Drive, Avon MA 2322
250 Hartford Avenue, Bellingham MA 2019
700 Oak Street, Brockton MA 2301
66-4 Parkhurst Rd, Chelmsford MA 1824
591 Memorial Dr, Chicopee MA 1020
55 Brooksby Village Way, Danvers MA 1923
137 Teaticket Hwy, East Falmouth MA 2536
42 Fairhaven Commons Way, Fairhaven MA 2719
374 William S Canning Blvd, Fall River MA 2721
@conschneider
conschneider / custom-email-sender.php
Created August 10, 2020 13:24 — forked from danielbitzer/custom-email-sender.php
AutomateWoo - Customize your email sender name #woo
<?php
// change the from name
add_filter( 'automatewoo/mailer/from_name', function( $from_name ) {
return 'My Custom From Name';
});
// change the from address
add_filter( 'automatewoo/mailer/from_address', function( $from_email ) {
return 'email@example.org';
@conschneider
conschneider / wordpress-valet-install.md
Created August 1, 2020 13:15 — forked from orumad/wordpress-valet-install.md
How to install Wordpress from command line in Valet

How to install Wordpress from command line in Valet

I use Valet as my local web development environment (PHP, Laravel, Wordpress, ...)

This gist is my own recipe to install Wordpress from the command line to use it with Valet. Maybe this is useful for you too.

Install 'WP-CLI' command line tool

@conschneider
conschneider / Enable WooCommerce image sizes in Customizer.php
Created June 16, 2019 10:15
This enables custom image sizes for WooCommerce in the Customizer even when the theme has declared the images sizes. This works with the Storefront theme.
<?php
/*
Plugin Name: Custom Image Sizes for WooCommerce
Plugin URI: https://themebynumbers.com/
Description: Let's you customize WooCommerce product image sizes from the Customizer
Version: 0.1
Author: Mikey Arce
Author URI: https://themebynumbers.com
Text Domain: custom_image_sizes_for_wc
Domain Path: /languages