From 4658999df4b43ae1b0225df13820b32248fd5bac Mon Sep 17 00:00:00 2001 From: "theAverageDev (Luca Tumedei)" Date: Mon, 19 Feb 2018 19:15:58 +0100 Subject: [PATCH] support the --reset-total-sales flag --- readme.txt | 5 ++++- src/Commerce/Command.php | 7 +++++++ src/Commerce/Generator/PayPal/CLI.php | 5 +++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 376c1429..3b5b3693 100755 --- a/readme.txt +++ b/readme.txt @@ -152,7 +152,10 @@ Our Premium Plugins: == Changelog == -= [0.2.1] 2017-01-19 = += [0.2.2] 2017-02-19 = +* Add support for the `--reset-deleted-sales` flag to the `reset-paypal-orders` command + += [0.2.1] 2017-02-18 = * Add support for the `--reset-deleted-attendees` flag to the `reset-paypal-orders` command * Add support for the `--dont-send-emails` flag to the `generate-paypal-orders` and `update-paypal-order-status` commands diff --git a/src/Commerce/Command.php b/src/Commerce/Command.php index 987f5690..68476d58 100644 --- a/src/Commerce/Command.php +++ b/src/Commerce/Command.php @@ -96,10 +96,17 @@ public function generate_paypal_orders( array $args = null, array $assoc_args = * [--reset-deleted-attendees] * : reset the number of deleted attendees * + * [--reset-total-sales] + * : reset the total sales to 0; for tickets only + * + * * ## EXAMPLES * * wp commerce reset-paypal-orders 23 * wp commerce reset-paypal-orders 23 --reset-deleted-attendees + * wp commerce reset-paypal-orders 23 --reset-total-sales + * wp commerce reset-paypal-orders 23 --reset-total-sales=3 + * wp commerce reset-paypal-orders 23 --reset-total-sales=3 --reset-deleted-attendees * * @subcommand reset-paypal-orders * diff --git a/src/Commerce/Generator/PayPal/CLI.php b/src/Commerce/Generator/PayPal/CLI.php index dc2b71fb..03da5774 100644 --- a/src/Commerce/Generator/PayPal/CLI.php +++ b/src/Commerce/Generator/PayPal/CLI.php @@ -538,6 +538,11 @@ public function reset_orders( array $args = array(), array $assoc_args = array() delete_post_meta( $target_id, Tribe__Tickets__Attendance::DELETED_ATTENDEES_COUNT ); WP_CLI::log( 'Deleted attendees count reset to 0' ); } + + if ( $is_ticket && isset( $assoc_args['reset-total-sales'] ) ) { + update_post_meta( $target_id, 'total_sales', 0 ); + WP_CLI::log( "Total sales count reset to 0" ); + } } /**