From 8a9990f98d618699e275aac6378f75801589d9c9 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Mon, 25 Feb 2019 06:01:38 +0100 Subject: [PATCH 1/2] [ADD] Do Action before cart is emptied --- includes/class-wc-cart.php | 1 + 1 file changed, 1 insertion(+) diff --git a/includes/class-wc-cart.php b/includes/class-wc-cart.php index 4d3fb52b4a6..dea6f2d433e 100644 --- a/includes/class-wc-cart.php +++ b/includes/class-wc-cart.php @@ -634,6 +634,7 @@ class WC_Cart extends WC_Legacy_Cart { * @param bool $clear_persistent_cart Should the persistant cart be cleared too. Defaults to true. */ public function empty_cart( $clear_persistent_cart = true ) { + do_action( 'woocommerce_empty_cart' ); $this->cart_contents = array(); $this->removed_cart_contents = array(); $this->shipping_methods = array(); From e442f46db3849da2c508eb8e509844307c3f6ec4 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Thu, 28 Feb 2019 21:56:43 +0100 Subject: [PATCH 2/2] Update class-wc-cart.php --- includes/class-wc-cart.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/includes/class-wc-cart.php b/includes/class-wc-cart.php index dea6f2d433e..6ba8058e383 100644 --- a/includes/class-wc-cart.php +++ b/includes/class-wc-cart.php @@ -634,7 +634,9 @@ class WC_Cart extends WC_Legacy_Cart { * @param bool $clear_persistent_cart Should the persistant cart be cleared too. Defaults to true. */ public function empty_cart( $clear_persistent_cart = true ) { - do_action( 'woocommerce_empty_cart' ); + + do_action( 'woocommerce_before_cart_emptied' ); + $this->cart_contents = array(); $this->removed_cart_contents = array(); $this->shipping_methods = array();