Skip to content

Instantly share code, notes, and snippets.

Avatar

Max Rice maxrice

View GitHub Profile
@maxrice
maxrice / jilt-for-wc-watch-email.php
Last active Nov 8, 2018
Jilt for WooCommerce - watch an email input and automatically set the customer when populated
View jilt-for-wc-watch-email.php
<?php
add_action( 'init', 'jilt_for_wc_add_custom_email_capture' );
function jilt_for_wc_add_custom_email_capture() {
if ( function_exists( 'wc_enqueue_js' ) ) {
ob_start();
?>
$(window).load(function() {
var opts = {
callback: function (value) {
@maxrice
maxrice / jilt-for-woocommerce-order-is-placed-filter.php
Created Feb 10, 2018
Jilt for WooCommerce - prevent pending orders placed with a certain payment gateway from being sent recovery emails
View jilt-for-woocommerce-order-is-placed-filter.php
<?php
add_filter( 'wc_jilt_order_is_placed', function( $placed, $order ) {
return $placed || ( 'pending' == $order->get_status() && 'divido' == $order->get_payment_method() );
}, 10, 2 );
@maxrice
maxrice / jilt-for-wc-clear-persistent-carts.php
Last active Jun 2, 2019
Jilt for WooCommerce - Clear persistent carts for customers who signed up over 30 days ago
View jilt-for-wc-clear-persistent-carts.php
<?php
add_filter( 'woocommerce_debug_tools', function( $tools ) {
$tools['wc_jilt_clear_persistent_carts'] = array(
'name' => __( 'Clear Persistent Carts from customers who signed up over 30 days ago.', 'jilt-for-woocommerce' ),
'button' => __( 'Clear', 'woocommerce-plugin-framework' ),
'desc' => __( 'This tool will clear the persistent cart for all registered customers who signed up over 30 days ago.', 'jilt-for-woocommerce' ),
'callback' => 'wc_jilt_clear_persistent_carts'
);
return $tools;
@maxrice
maxrice / jilt-for-wc-force-individual-use-coupons.php
Created Jan 31, 2018
Jilt for WooCommerce - force individual use for coupons created by Jilt
View jilt-for-wc-force-individual-use-coupons.php
<?php
add_filter( 'woocommerce_coupon_get_individual_use', function( $individual_use, $coupon ) {
if ( $coupon->meta_exists( 'jilt_discount_id' ) ) {
$individual_use = true;
}
return $individual_use;
}, 10, 2 );
@maxrice
maxrice / jilt-for-wc-disable-email-field-move.php
Created Oct 11, 2017
Jilt for WooCommerce - Disable moving the email field at checkout
View jilt-for-wc-disable-email-field-move.php
<?php
add_action( 'init', function() {
if ( is_callable( 'wc_jilt' ) ) {
remove_filter( 'woocommerce_checkout_fields', array( wc_jilt()->get_checkout_handler_instance(), 'move_checkout_email_field' ), 1 );
}
}, 20 );
@maxrice
maxrice / jilt-for-wc-recovery-link-redirect-to-cart.php
Created Oct 10, 2017
Jilt for WooCommerce - Recovery link redirect to cart
View jilt-for-wc-recovery-link-redirect-to-cart.php
@maxrice
maxrice / wc-customer-order-csv-export-add-order-customer-ip.php
Created Dec 7, 2015
WooCommerce Customer/Order CSV Export - add order customer IP column
View wc-customer-order-csv-export-add-order-customer-ip.php
<?php
// add customer IP column header
function wc_csv_export_add_customer_ip_column_header( $column_headers ) {
$new_headers = array(
'customer_ip' => 'customer_ip',
);
return array_merge( $column_headers, $new_headers );
@maxrice
maxrice / wc-auth-net-cim-save-payment-method-default-checked.php
Created Aug 3, 2015
WC Authorize.net CIM: On the payment form, default "securely save to account" checkbox to checked
View wc-auth-net-cim-save-payment-method-default-checked.php
<?php
// force the "securely save to account" checkbox to default to checked
function wc_auth_net_cim_save_payment_method_default_checked( $html, $form ) {
if ( empty( $html ) || $form->tokenization_forced() ) {
return $html;
}
return str_replace( 'type="checkbox"', 'type="checkbox" checked="checked"', $html );
}
@maxrice
maxrice / wc-auth-net-cim-adjust-auth-only-order-status.php
Last active Oct 19, 2020
WooCommerce Authorize.net CIM: Adjust authorize-only transaction order status
View wc-auth-net-cim-adjust-auth-only-order-status.php
<?php
function sv_wc_auth_net_cim_tweak_held_order_status( $order_status, $order, $response ) {
if ( 'on-hold' === $order_status && $response instanceof SV_WC_Payment_Gateway_API_Response && $response->transaction_approved() ) {
$order_status = 'processing';
}
return $order_status;
}
@maxrice
maxrice / wc-local-pickup-plus-remove-pickup-location.php
Created Jun 9, 2015
WooCommerce Local Pickup Plus - Remove pickup location action
View wc-local-pickup-plus-remove-pickup-location.php
function wc_local_pickup_plus_remove_pickup_location() {
$methods = WC()->shipping->load_shipping_methods();
if ( isset( $methods['local_pickup_plus'] ) ) {
remove_action( 'woocommerce_after_template_part', array( $methods['local_pickup_plus'], 'review_order_shipping_pickup_location' ), 10, 4 );
}
}
add_action( 'wc_shipping_local_pickup_plus_init', 'wc_local_pickup_plus_remove_pickup_location' );