Merge pull request #28027 from woocommerce/pp_response_check_for_cart

Check the cart exists before emptying it after handling PayPal response
This commit is contained in:
Roy Ho 2020-10-27 08:54:56 -07:00 committed by GitHub
commit 99fcafee8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -66,7 +66,10 @@ abstract class WC_Gateway_Paypal_Response {
if ( ! $order->has_status( array( 'processing', 'completed' ) ) ) {
$order->add_order_note( $note );
$order->payment_complete( $txn_id );
WC()->cart->empty_cart();
if ( isset( WC()->cart ) ) {
WC()->cart->empty_cart();
}
}
}
@ -78,6 +81,9 @@ abstract class WC_Gateway_Paypal_Response {
*/
protected function payment_on_hold( $order, $reason = '' ) {
$order->update_status( 'on-hold', $reason );
WC()->cart->empty_cart();
if ( isset( WC()->cart ) ) {
WC()->cart->empty_cart();
}
}
}