This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'woocommerce_before_cart_table', 'free_shipping_notice' ); | |
add_action( 'woocommerce_checkout_before_customer_details', 'free_shipping_notice' ); | |
function free_shipping_notice() { | |
if ( 25 > WC()->cart->get_total() ) { | |
echo '<div style="color: #e08e79;">All orders over $25 ship free</div>'; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'woocommerce_email_subject_new_order', 'customizing_new_order_subject', 10, 2 ); | |
function customizing_new_order_subject( $formated_subject, $order ) { | |
$email = WC()->mailer->get_emails()['WC_Email_New_Order']; | |
$subject = $email->get_option( 'subject', $email->get_default_subject() ); | |
$product_categories = array(); | |
foreach ( $order->get_items() as $item ) { | |
$product_categories[] = implode( ', ', wp_get_post_terms( $item->get_product_id(), 'product_cat', array( 'fields' => 'names' ) ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
additionalFields.forEach( ( { label, type, required, options = '' } ) => { | |
if ( '' !== type ) { | |
var MD5 = function(d){var r = M(V(Y(X(d),8*d.length)));return r.toLowerCase()};function M(d){for(var _,m="0123456789ABCDEF",f="",r=0;r<d.length;r++)_=d.charCodeAt(r),f+=m.charAt(_>>>4&15)+m.charAt(15&_);return f}function X(d){for(var _=Array(d.length>>2),m=0;m<_.length;m++)_[m]=0;for(m=0;m<8*d.length;m+=8)_[m>>5]|=(255&d.charCodeAt(m/8))<<m%32;return _}function V(d){for(var _="",m=0;m<32*d.length;m+=8)_+=String.fromCharCode(d[m>>5]>>>m%32&255);return _}function Y(d,_){d[_>>5]|=128<<_%32,d[14+(_+64>>>9<<4)]=_;for(var m=1732584193,f=-271733879,r=-1732584194,i=271733878,n=0;n<d.length;n+=16){var h=m,t=f,g=r,e=i;f=md5_ii(f=md5_ii(f=md5_ii(f=md5_ii(f=md5_hh(f=md5_hh(f=md5_hh(f=md5_hh(f=md5_gg(f=md5_gg(f=md5_gg(f=md5_gg(f=md5_ff(f=md5_ff(f=md5_ff(f=md5_ff(f,r=md5_ff(r,i=md5_ff(i,m=md5_ff(m,f,r,i,d[n+0],7,-680876936),f,r,d[n+1],12,-389564586),m,f,d[n+2],17,606105819),i,m,d[n+3],22,-1044525330),r=md5_ff(r,i=md5_ff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'woocommerce_return_to_shop_redirect', function() { return '/shop'; }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('woocommerce_price_format', 'woo_custom_format_position', 999, 2); | |
function woo_custom_format_position( $format, $currency_pos ) | |
{ | |
/*'left':$format = '%1$s%2$s'; | |
'right':$format = '%2$s%1$s'; | |
'left_space':$format = '%1$s %2$s'; | |
'right_space':$format = '%2$s %1$s'; | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if( get_current_user_id() > 0 ) { // if customer exists already | |
$country = WC()->customer->get_billing_country(); | |
} else { // if not-logged-in, need to use geolocation data | |
// Get an instance of the WC_Geolocation object class | |
$geo_instance = new WC_Geolocation(); | |
// Get geolocated user geo data. | |
$user_geodata = $geo_instance->geolocate_ip(); | |
// Get current user GeoIP Country |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Save custom calculated price as custom cart item data | |
add_filter( 'woocommerce_add_cart_item_data', 'save_custom_fields_data_to_cart', 10, 2 ); | |
function save_custom_fields_data_to_cart( $cart_item_data, $product_id ) { | |
if ( CUSTOMER_IS_IN_US ) { | |
// Set the custom data in the cart item | |
$cart_item_data['custom_price'] = GET_PRICE_FROM_CUSTOM_FIELD; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Place this snippet in config.php file | |
// Suspend all updates when outside of business hours, 9:00 AM to 5:30 PM | |
$updates_suspended = (date('Hi') < 0900 || date('Hi') > 1730); | |
define( 'AUTOMATIC_UPDATER_DISABLED', $updates_suspended ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Plugin Autoupdate Filter | |
Plugin URI: https://gist.github.com/NickGreen/a66d349575cf9e78c6dafd92efa5288a/edit | |
Description: Plugin which sets plugin autoupdates to always on, but only happen during specific times. | |
Version: 1.0 | |
Author: Nick Green | |
Author URI: | |
License: GPLv3 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Export a database backup beforehand | |
wp-cli db export --path=/htdocs/__wp__ | |
# Get a list of tables missing primary kkeys | |
TABLES=$(wp-cli --path=/htdocs/__wp__ db query 'SELECT TABLES.TABLE_NAME FROM INFORMATION_SCHEMA.TABLES LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS c ON ( TABLES.TABLE_NAME = c.TABLE_NAME AND c.CONSTRAINT_SCHEMA = TABLES.TABLE_SCHEMA AND c.constraint_name = "PRIMARY" ) WHERE c.constraint_name IS NULL AND TABLE_TYPE = "BASE TABLE"') | |
NewerOlder