Skip to content

Instantly share code, notes, and snippets.

View billrobbins's full-sized avatar

Bill Robbins billrobbins

View GitHub Profile
@billrobbins
billrobbins / woocommerce-order-status-logging.php
Created December 8, 2022 14:24
ChatGPT generated plugin to track WooCommerce order status changes to a custom database table.
<?php
/*
* Plugin Name: WooCommerce Order Status Tracker
* Plugin URI: https://example.com/woocommerce-order-status-tracker
* Description: This plugin tracks WooCommerce order status changes and logs them to the database.
* Version: 1.0.0
* Author: Your Name
* Author URI: https://example.com
* License: GPL2
*/
.woocommerce .col2-set .col-1, .woocommerce .col2-set .col-2 {
flex: none;
}
CREATE TABLE wp_woocommerce_square_customers (`square_id` varchar(191) NOT NULL, `email_address` varchar(200) NOT NULL, `user_id` BIGINT UNSIGNED NOT NULL, PRIMARY KEY (`square_id`) )
add_filter( 'automatewoo/batched_job_monitor/failure_rate_threshold', 'woo_set_custom_failure_rate' );
function woo_set_custom_failure_rate ($threshold ) {
return 10000;
}
// Changes the amount of time a WooCommerce Booking can remain in the cart before it is removed. Time is in minutes.
function ijab_change_inactive_cart_bookings_time() {
return 5;
}
add_filter( 'woocommerce_bookings_remove_inactive_cart_time', 'ijab_change_inactive_cart_bookings_time' );
<?php
function ijab_woo_remove_order_meta_search() {
return;
}
add_filter( 'woocommerce_shop_order_search_fields', 'ijab_woo_remove_order_meta_search' );
function sv_facebook_feed_url_admin_notice(){
if ( class_exists( 'WC_Facebook_Product_Feed' ) ) {
$feed_file_url = class_exists( 'SkyVerge\WooCommerce\Facebook\Products\Feed' ) ? get_bloginfo( 'url' ) . '/?wc-api=wc_facebook_get_feed_data&secret=' . SkyVerge\WooCommerce\Facebook\Products\Feed::get_feed_secret() : '';
if ( ( isset( $_GET['page'], $_GET['tab'], $_GET['section'] ) &&
( 'wc-settings' == $_GET['page'] && 'integration' == $_GET['tab'] &&
'facebookcommerce' == $_GET['section'] ) ) ||
( isset( $_GET['page'] ) && 'wc-facebook' == $_GET['page'] ) ) {
add_action( 'customize_register', 'jp_override_storefront_powerpack', 21 );
/**
* @param WP_Customize_Manager $wp_customizer
*/
function jp_override_storefront_powerpack( $wp_customizer ) {
$controls = array(
'sp_homepage_featured_products_limit',
'sp_homepage_top_rated_products_limit',
'sp_homepage_on_sale_products_limit',
'sp_homepage_recent_products_limit',
<?php
add_filter( 'woocommerce_states', 'ijab_add_puerto_rico_wc_states' );
function ijab_add_puerto_rico_wc_states( $states ) {
$states['US'] = array(
'AL' => __( 'Alabama', 'woocommerce' ),
'AK' => __( 'Alaska', 'woocommerce' ),
'AZ' => __( 'Arizona', 'woocommerce' ),
'AR' => __( 'Arkansas', 'woocommerce' ),
// This function disables the Stripe gateway everywhere except for the order-pay endpoint.
// It also removes the Check gateway from the order-pay endpoint.
function ijab_selected_gateways_order_pay( $available_gateways ) {
if ( is_checkout() && ! is_wc_endpoint_url( 'order-pay' ) ) {
unset( $available_gateways[ 'stripe' ] );
}
if ( is_checkout() && is_wc_endpoint_url( 'order-pay' ) ) {