Skip to content

Instantly share code, notes, and snippets.

Avatar

Devin Price devinsays

View GitHub Profile
@devinsays
devinsays / update-coupon-data.php
Created February 25, 2023 20:11
Updates coupon data in the verification table for WooCommerce Coupon Restrictions
View update-coupon-data.php
<?php
/**
* Workaround to load historic data if WP CLI is not installed.
* Update the $code variable to match the coupon code you want to update.
*
* This code can be loaded in a custom plugin or in your theme's functions.php file.
*
* A transient is used to prevent the data from being updated more than once,
* but this code should be removed as soon as it has run and the table is updated.
*/
@devinsays
devinsays / delete-completed-order-meta.php
Created December 28, 2022 18:18
Deletes meta data from completed orders created more than 90 days ago.
View delete-completed-order-meta.php
<?php
/**
* Delete postmeta for completed orders created more than X days ago.
*
* To delete meta on completed orders run:
* wp eval-file delete-completed-order-meta.php
*/
// Transient allows the script to resume where it left off if interrupted.
$transient_name = 'last_processed_order';
@devinsays
devinsays / schedule-products-sale.php
Created November 23, 2022 16:47
WP CLI script schedule a product sale in WooCommerce.
View schedule-products-sale.php
<?php
/**
* WP CLI script to schedule a sale for specific dates.
*
* To support scheduled sales to the hour/minute, use this free plugin:
* https://wordpress.org/plugins/precise-sales-for-woocommerce/
*
* wp eval-file schedule-products-sale.php
*/
if ( ! defined( 'ABSPATH' ) ) {
@devinsays
devinsays / coupon-generator.php
Last active April 7, 2023 15:48
WP CLI script for generating coupon copies
View coupon-generator.php
<?php
/**
* Generate coupon copies from an existing coupon.
* Replaces UNQCODE with a unique generated coupon code.
*
* For more information about this script:
* https://devpress.com/wp-cli-script-to-duplicate-woocommerce-coupons/
*
* wp eval-file coupon-generator.php
*/
@devinsays
devinsays / sync-config.sh
Created October 21, 2022 21:31
Bash script for syncing WP Engine production to local
View sync-config.sh
sshenv=yoursite
replace=('yoursite.com' 'yoursite.local')
@devinsays
devinsays / .gitignore
Created October 19, 2022 02:57
GitIgnore Example for WooCommerce
View .gitignore
# Filetypes
*.sql
debug.log
.DS_Store
# Directories
node_modules/
/tmp/
/vendor/
@devinsays
devinsays / channel-logic.php
Last active October 4, 2022 19:51
Fulfil channel logic
View channel-logic.php
<?php
/**
* Determine which Fulfil channel ID to use based on order type, source.
*
* @param Order $order Order to check
*
* @return mixed
*/
public static function getChannelId(Order $order)
{
@devinsays
devinsays / OrdersList.php
Created June 2, 2022 15:45
Speeds up the loading of /wp-admin/edit.php?post_type=shop_order and /wp-admin/edit.php?post_type=subscription.
View OrdersList.php
<?php
namespace UniversalYums\Admin\Performance;
class OrdersList {
/**
* The single instance of the class.
*/
protected static $instance;
@devinsays
devinsays / ActionSchedulerHighVolume.php
Last active March 24, 2023 14:25
Modifications to Action Scheduler in order to run higher volumes of actions.
View ActionSchedulerHighVolume.php
<?php
/**
* High volume modifications to Action Scheduler.
*
* Adapted from https://github.com/woocommerce/action-scheduler-high-volume/
*
* Increase Action Scheduler batch size, concurrency, timeout period, and claim action query
* ORDER BY to process large queues of actions more quickly on servers with more server resources.
*
* @package UniversalYums\ActionScheduler
@devinsays
devinsays / performance.php
Created November 19, 2021 18:17
Dequeue scripts and styles
View performance.php
<?php
namespace DevPress\Frontend;
/**
* Class Performance
*
* @package DevPress\Performance
*/
class Performance {