From e420953c3967ea4b931a603b0abbfab67f8984c3 Mon Sep 17 00:00:00 2001 From: Almira Krdzic Date: Mon, 22 Oct 2018 09:52:01 +0200 Subject: [PATCH] do not set cart cookies --- .../app/plugins/wiaas/includes/class-wiaas-cart.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-cart.php b/backend/app/plugins/wiaas/includes/class-wiaas-cart.php index 96fb225..98c75f4 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-cart.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-cart.php @@ -28,6 +28,18 @@ class Wiaas_Cart { add_action( 'woocommerce_cart_loaded_from_session', array( __CLASS__, 'on_calculate_totals' ), 99, 1); add_action('woocommerce_checkout_create_order', array(__CLASS__, 'add_additional_order_data'), 99); + + add_action('woocommerce_set_cart_cookies', array(__CLASS__, 'do_not_set_cart_cookies')); + } + + /** + * Do not set cart cookies + */ + public static function do_not_set_cart_cookies() { + if ( isset( $_COOKIE['woocommerce_items_in_cart'] ) ) { + wc_setcookie( 'woocommerce_items_in_cart', 0, time() - HOUR_IN_SECONDS ); + wc_setcookie( 'woocommerce_cart_hash', '', time() - HOUR_IN_SECONDS ); + } } /**