Skip to content

Instantly share code, notes, and snippets.

View nhadsall's full-sized avatar

Nathan nhadsall

View GitHub Profile
@nhadsall
nhadsall / refund.php
Created October 11, 2022 00:52 — forked from growdev/refund.php
Bulk Refund WooCommerce Orders using CSV file input.
<?php
/**
* Bulk Refund Orders
*
* This script expects a csv file with following columns:
* - Order ID 1002
* - Reason for refund 'Item was oversold.'
* - Amount to refund '34.56'
* - Refund payment true/false
* - Restock item true/false
@nhadsall
nhadsall / fix_get_total_spent.php
Last active March 29, 2023 11:28
Fix WooCommerce get_total_spent()
<?php
class SPROUT_order_total {
private $orders = [];
function __construct() {
add_action( "woocommerce_before_order_object_save", [ $this, 'save_order' ], 1000, 2 );
add_filter( "woocommerce_customer_get_total_spent_query", [ $this, 'intercept_query' ], 1000, 2 );
}
function intercept_query( $query, $customer ) {