parent::handle_error($send_response); } /** * Replaces the real cart with the clone. * * @return void */ private function replace_real_cart() { // Set WC default cart as the clone. // Store a reference to the real cart. $this->real_cart = WC()->cart; WC()->cart = $this->cart; $this->cart_products->set_cart($this->cart); } /** * Restores the real cart. * Currently, unsets the WC cart to prevent race conditions arising from it being persisted. * * @return void */ private function restore_real_cart() { // Remove from cart because some plugins reserve resources internally when adding to cart. $this->remove_cart_items(); if (apply_filters('woocommerce_paypal_payments_simulate_cart_prevent_updates', \true)) { // Removes shutdown actions to prevent persisting session, transients and save cookies. remove_all_actions('shutdown'); unset(WC()->cart); } else if (null !== $this->real_cart) { WC()->cart = $this->real_cart; } unset($this->cart); } }