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 / 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 ) {
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

/**
* wc_shipment_tracking_add_custom_provider
*
* Adds custom provider to shipment tracking
* Change the country name, the provider name, and the URL (it must include the %1$s)
* Add one provider per line
*/
add_filter( 'wc_shipment_tracking_get_providers' , 'wc_shipment_tracking_better_hermes' );
@conschneider
conschneider / css
Created June 16, 2020 13:54 — forked from PadreZippo/embed.html
iframes with constant aspect ratios
.ratio-16-9,
.ratio-16-10,
.ratio-square {
display: block;
position: relative;
width: 100%;
height: 0;
}
.ratio-16-9 {
@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 / WP OneSignal Push To App.php
Created May 28, 2020 20:06
Sets the URL to app_url so that OneSignal WordPress Push Notifications open the app instead of phone browser. Disables Browser Notifications.
<?php
/*
Plugin Name: WP OneSignal Push To App
Description: Sets the URL to app_url so that OneSignal WordPress Push Notifications open the app instead of phone browser. Disables Browser Notifications.
Version: 1.0
Author: Con & Anna Schneider
Author URI: https://conschneider.de
*/
// If this file is called directly, abort.
@conschneider
conschneider / Statamic: Exclude collection entries by taxonomy tag custom filter.php
Created May 13, 2020 18:03
Filter a collection by taxonomy tag and exclude entries with a specific taxonomy.
<?php
namespace Statamic\Addons\StartTax;
use Statamic\Extend\Filter;
class StartTaxFilter extends Filter
{
/**
* This excludes entries that have a specific tag set. In this case 'Startseite'.
@conschneider
conschneider / function.php
Created May 6, 2020 17:13 — forked from setola/function.php
Wordpress - excerpt with wysiwyg editor
<?php
/**
* This class removes the default excerpt metabox
* and adds a new box with the wysiwyg editor capability
* @author etessore
*/
class TinyMceExcerptCustomization{
const textdomain = '';
const custom_exceprt_slug = '_custom-excerpt';